I have been experimenting with the
index.htm
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="main.css">
<!--<script type = "text/javacript" src="http://code.jquery.com/jquery-latest.js"></script>-->
<script type = "text/javacript" src="main.js"></script>
</head>
<body onload = "console.log('Page fully loaded');">
<canvas id="mainCanvas" width = "200" height = "200" onContextMenu="javascript: return false;">Canvas not supported.</canvas>
Sample Text
</body>
</html>
main.js
function main()
{
var canvas = document.getElementById("mainCanvas");
var ctx=canvas.getContext("2d");
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,150,75);
console.log("Drew rectangle");
} When I click the paragraph, Chrome's console gives me the message, "Uncaught ReferenceError: main is not defined." The css file is used perfectly. If I inspect the script element that contains the link to main.js, it'll show the correct path to it in a tooltip. I can't figure out what's going wrong.