javascript function does not work when used <!DOCTYPE html> -
given next code:
class="snippet-code-js lang-js prettyprint-override">function move() { dom = document.getelementbyid('image'); dom.style.top=event.clienty+"px"; dom.style.left=event.clientx+"px"; }
class="snippet-code-html lang-html prettyprint-override"><!doctype html> <html> <head> <title>program 3</title> <script type="text/javascript" src="pr3.js"></script> </head> <body onmousedown="move();"> <img src="image.jpg" id="image" width="300px" height="200px" style="position:absolute; left:100px; top:100px;"/> </body> </html>
edit
the image moves when clicked on image. when clicked outside image, not move.
however, without <!doctype html>
, moves wherever clicked within browser window , not explicitly on image.
the problem in "quirks mode" body height set 100%, while in "standards mode" determined content. without doctype(rendering in quirks mode) whole page area body - clickable, in "standards mode" image...
if want can in "standards mode", applying next css:
html, body { height: 100%; }
working example: http://plnkr.co/edit/wrhs3b8nq9tfi5amwqoe?p=preview
javascript html doctype
No comments:
Post a Comment