I’m making a browser-based clone of an old strategy game called Diplomacy. This is what I’ve got so far:
<html>
<head>
<title>Diplomacy</title>
<script type="text/javascript" src="game.js" />
</head>
<body>
<canvas id="canvas" width="750" height="750" style="border: 3px solid black; background:url('DiplomacyMap.png');">
Your browser does not support Canvas.
</canvas>
</body>
</html>
What does it look like in-browser? A blank page. However, if I remove the link to the external JS file in the head (game.js), it shows up no problem. This doesn’t appear to have to do with the contents of the JS file, as even if I delete them or comment them all out, the problem persists. It seems to be to do with the mere presence of the element.
If I replace the <script src="file.js"> element with an embedded <script> ...code... </script>, the page works fine.
So… what’s going on?
PART 2:
<script type="text/javascript">
colorProvince(PARIS, FRANCE);
</script>
Although the colorProvince function and the PARIS and FRANCE constants are all defined in game.js, this function isn’t being called (as verified by a simple alert() in the colorProvince function). This doesn’t do anything, either:
<script type="text/javascript">
alert(colorProvince);
</script>
needs to be
and in game.js there is an extra semicolon in
colorProvince(). replace it with this: