Using javascript in a HTMLViewer

I want to make a simple web page and display is using a HTMLViewer.
The code below is the source of the page, with one thing missing.
I need to populate the Paint() method with what I want to do.
I could search for $$ and replace it with the code I want.
Then I think I can call LoadPage(theString)

So this is the html string. I can make it a class property and modify it before I pass it to LoadPage.
Is there a better way to do this? Should I be thinking of the page source as XML?
As the model changes and I want to update my view I believe I can just call LoadPage again…

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
	<canvas id="myCanvas" width="640" height="2000"></canvas>
	<script>
        function myFirstFunction() {
        }
        function mySecondFunction() {
        }
        function Paint() {
              $$
        } 
        Paint();
        </script>
   </body>
</html>

shameful bump…

Excellent! Merci.

This is a great tutorial, but I’m not sure how to use it in combination with a HTMLViewer and Xojo?
I already know how to draw object on the canvas.

[quote=185562:@Brian O’Brien]I want to make a simple web page and display is using a HTMLViewer.
The code below is the source of the page, with one thing missing.
I need to populate the Paint() method with what I want to do.
I could search for $$ and replace it with the code I want.
Then I think I can call LoadPage(theString)

So this is the html string. I can make it a class property and modify it before I pass it to LoadPage.
Is there a better way to do this? Should I be thinking of the page source as XML?
As the model changes and I want to update my view I believe I can just call LoadPage again…

[code]

body { margin: 0px; padding: 0px; } [/code][/quote]

That should work. Just give it a try.

I know this will work. I just think I’ve misunderstood the design and intended use of execute java script …
I think there is a better way to do this then the way I’m attempting to do it, which in my mind seems ‘hackish’.

[quote=185765:@Brian O’Brien]I know this will work. I just think I’ve misunderstood the design and intended use of execute java script …
I think there is a better way to do this then the way I’m attempting to do it, which in my mind seems ‘hackish’.[/quote]

Building a page and displaying it is not hackish. It is just one way. It is done in millions of sites in Php, Perl, whatever.

In Xojo, you have the choice to use ExecuteJavaScript – or not. All depend what you need to do. You can even use the WebSDK to build your own control.

That is the beauty of programming. You got several possibilities, and choose the one that suits your mind.

Since I have no idea what kind of JavaScript you want to put into your page, I suppose you have excellent reasons to proceed the way you posted. As I just said in another thread a few minutes ago, at one point science, and computer science especially, has to be experimented rather than speculated. Just try the damn thing, and if it does not work, you got other possibilities.

shouldn’t the javascript be loaded as a library and then referenced in the page source?

[quote=185780:@Michel Bujardet]Building a page and displaying it is not hackish. It is just one way. It is done in millions of sites in Php, Perl, whatever.

In Xojo, you have the choice to use ExecuteJavaScript – or not. All depend what you need to do. You can even use the WebSDK to build your own control.

That is the beauty of programming. You got several possibilities, and choose the one that suits your mind.

Since I have no idea what kind of JavaScript you want to put into your page, I suppose you have excellent reasons to proceed the way you posted. As I just said in another thread a few minutes ago, at one point science, and computer science especially, has to be experimented rather than speculated. Just try the damn thing, and if it does not work, you got other possibilities.[/quote]

No. You may want to add this only if you need jQuery.

[code]

[/code]

Are you sure you really want to use JavaScript instead of Xojo pictures, though ?