- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Script validated by W3C, but not displaying in browser.
Hi all,
I copied some code from a powerpoint page displayed during a web seminar given by CiW. It is supposed to display a Diver Down flag (red flag with diagonal white stripe). I added some head code to my notepad file and it passed validation by W3C, but won’t run on any browser, although the text “Your browser does not support the canvas tag.” does display in IE only. Any ideas how I can get this to work?
Thanks in anticipation.
The code is:
<!DOCTYPE html>
<html>
<head>
<title>Diver Down JS CiW Example</title>
<meta charset=”utf-8″ />
<body>
<canvas id=”myCanvas”>Your browser does not support the canvas tag.</canvas>
<script type=”text/javascript”>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
// Draw red line
ctx.fillStyle = '#FF0000';
ctx.fillRect(0, 0, 125, 75);
// Draw white downward diagonal line
ctx.beginPath();
ctx.lineWidth = "15";
ctx.strokeStyle = "white";
ctx.moveTo(0, 0,);
ctx.lineTo(125, 75,);
ctx.stroke();
</script>
</body>
</html>
I don’t know JS all that well…but when I threw that lot into Codepen it threw a bunch of errors in the JS.
Thank you nkrisc!
Who would have thought two commas could wreak so much havoc.
Best wishes.