Drawing Graphics with onmousedown
Hi
I am trying to add graphics without refreshing the page. This works ok when I load the graphics by some other means, but if I load the graphics using onmousedown(), the graphic is loaded, but the rest of the page disappears.
<div STYLE="solid red 1px; " id="playarea1" style=" margin: 75px 35px 35px 155px; width: 1600px; height: 600px; background-color: #FFFFCC" onmousedown="drawShape()">
This works okay:
document.write('<img id="cross" src="cross.jpg" style="position:absolute; width:5px; left:10px; top:10px;"/>’)
document.write('<img id="cross" src="cross.jpg" style="position:absolute; width:5px; left:20px; top:20px;"/>’)
document.write('<img id="cross" src="cross.jpg" style="position:absolute; width:5px; left:30px; top:30px;"/>’)
The three graphics are draw one after another and the rest of the page remains.
This does not work:
function drawShape(){
document.write('<img id="cross" src="cross.jpg" style="position:absolute; width:5px; left:100px; top:100px;"/>');
}
The remainder of the page disappears and only the graphic is shown. Can anyone please say why?
Regards
Lawrence