I wrote this code in JavaScript and works great when I include it in my index.html page:
<canvas id="bannerCanvas" width="960" height="200"> Your browser does not support the canvas element. </canvas> <script type="text/javascript"> var canvas = document.getElementById("bannerCanvas"); var context = canvas.getContext("2d"); context.beginPath(); context.moveTo(25,25); context.lineTo(355,55); context.lineTo(355,125); context.lineTo(25,125); context.moveTo(465,25); context.fill(); }; </script>
... however, when I put it in an external JavaScript file, it will not work! In the header of the index page, I stated the following:
<script type="text/javascript" src="JavaScript/functionality.js"> </script>
And I save this functions.js file in the JavaScript directory, I tried to do other JS functions in this file to check the index page, and the JS are connected, and they ... The answer is probably a person, but somehow I don’t see his!
Any help is much appreciated, thanks.
EDIT: I used Firebug and it does not give me any errors, when I use the code on the index page, I see the form that I want even when using an external JS file. I just see a big black rectangle.
source share