Skip to main content
Known Participant
April 19, 2018
Answered

Html5 canvas not working in dreamweaver cc

  • April 19, 2018
  • 3 replies
  • 1085 views

I am trying to use canvas in html5 and this is a sample that I have seen work but not working in my dreamweaver cc

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>bumple test</title>


</head>

<body>
<canvas id="myCanvas" width="200" height="200" style="border: 1px solid #999999">
 
</canvas>

<script type="application/javascript" language="javascript">

var c =document.getElementById("myCanvas");

var ctx= c.get.Context("2d");
 
ctx.beginPath();
ctx.fillStyle="green";
ctx.fillRect(0,0,100,100);
 
  what am I doing wrong,  I get the grey screen but doesn't move onto canvas.

Thanks

Jen
 
 
</script>
 

    This topic has been closed for replies.
    Correct answer Jon Fritz

    If it's only displaying a gray box, that would hint that you are in Design View rather than Live View.

    Design View doesn't run scripts. Live View might be closer to what you want, but the only way to truly see what's going to happen with your code is to open it in an actual browser.

    3 replies

    bumples5Author
    Known Participant
    April 20, 2018

    It is not working in browser, chrome or internet and live view in dreamweaver. 

    Thank you for trying to answer the question, but hope this helps.

    Jen

    Nancy OShea
    Community Expert
    April 20, 2018

    What's the URL to your problem page online?

    Nancy O'Shea— Product User & Community Expert
    Jon Fritz
    Community Expert
    April 19, 2018

    You also have an error...

    var ctx= c.get.Context("2d");

    should be

    var ctx= c.getContext("2d");

    (no . within getContext)

    Jon Fritz
    Jon FritzCorrect answer
    Community Expert
    April 19, 2018

    If it's only displaying a gray box, that would hint that you are in Design View rather than Live View.

    Design View doesn't run scripts. Live View might be closer to what you want, but the only way to truly see what's going to happen with your code is to open it in an actual browser.