Why doesn't linking Javascript files from header work but only at the end of the html works? -
i'm playing around kinetic.js , noticed linking javascript @ end of body
work. wouldn't adding javascript in head
work?
here html
<!doctype html> <html> <head> <title>tictactoe</title> <meta http-equiv="content-script-type" content="type"> </head> <body> <div id="container"></div> <script type="text/javascript" src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.4.0.min.js"></script> <script type="text/javascript" src="javascript.js"></script> </body> </html>
and here javascript file:
var stage = new kinetic.stage({ container: 'container', width: 500, height: 500 }); var layer = new kinetic.layer(); var rect = new kinetic.rect({ x: 239, y: 75, width: 150, height: 50, fill: 'green', stroke: 'black', strokewidth: 4 }); // add shape layer layer.add(rect); stage.add(layer);
it because has load html element before runs. try using "onload()" function fix this.
Comments
Post a Comment