homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

DHTML Javascript Graphics

10+ Year Member

Msg#: 466 posted 2:39 pm on Jun 27, 2003 (gmt 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>





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

Msg#: 466 posted 3:02 pm on Jun 27, 2003 (gmt 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()?


10+ Year Member

Msg#: 466 posted 7:25 pm on Jun 28, 2003 (gmt 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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved