Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

DHTML Javascript Graphics

2:39 pm on Jun 27, 2003 (gmt 0)

New User

10+ Year Member

joined:June 24, 2003
votes: 0

Trying to draw a Rectangle on a Layer so I can eventually move it around. This is pretty basic but can't seem to get it to work. The below code should just draw the rectangle on clicking of the button. Please help.

<div id="myCanvas" style="position:relative;height:50%;width:50%;"></div>
<script type="text/javascript" src="wz_jsgraphics.js"></script>

<script type="text/javascript">

var jg = new jsGraphics("myCanvas");

function myDrawFunction()
jg.fillRect(110, 120, 30, 60);




<title>New Page 1</title>

<input type="button" value="Button" name="B3" onclick="myDrawFunction()"></p>



3:02 pm on June 27, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 20, 2002
votes: 0

Welcome to the board daddywhite,

Is the code above how the page looks? Are you placing all of that code outside the HTML tag? Why do you have an orphan myDrawFunction() call in the script tag?

I am also assuming that the wz_jsgraphics.js has the object functions like paint()?

7:25 pm on June 28, 2003 (gmt 0)

New User

10+ Year Member

joined:June 24, 2003
votes: 0

I have managed to get it fixed now, thanks anyway for your reply.
The bit I was missing was in capitals below:

<div id="myCanvas" style="position:relative;height:50%;width:50%;">HELLO</div>

For some reason it would not draw anything on the layer until I have some text placed on the layer. Is there a way round this? Rather than having 'HELLO' or whatever on my page?

I have set the colour of this text to white so I cant be seen but even so would like to know why it would not work first time.