Skip to main content
Known Participant
Dec 23, 2017 9:15 PM UTC
Answered

canvas will not load in live demo or on the browsers

I am trying out canvas and can not see it in the live load or any browsers. here is the code.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>


<script>

window onload = function(){
  var myCanvas = document.getElementById('myCanvas')
  var ctx = myCanvas.getContext("2d");
 
  ctx.beginPath();
  ctx.arc(260,150,100,0, math PI*2, true);
  ctx.closePath();
  ctx.fill()l
 
}

</script>

</head>

<body>
<canvas id ="myCanvas" width="400" height="300" style="border:10px solid #000000;"></canvas>

</body>
</html>

I tried several different types in canvas.  what is the problem?

thanks

jen

    This topic is closed to new replies. Start a new post to keep the conversation going.
    BenPleysier
    BenPleysierCorrect answer
    Community Expert
    Dec 24, 2017 12:44 AM UTC

    Have a look at

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>Untitled Document</title>

    </head>

    <body>

    <canvas id ="myCanvas" width="400" height="300" style="border:10px solid #000000;"></canvas>

    <script>

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

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

    ctx.beginPath();

    ctx.arc(260,150,100,0, Math.PI*2);

    ctx.fill();

    </script>

    </body>

    </html>

    Where I have used the correct syntax as in "Math.PI" and not made a typo by typing "l" instead of ";".

    The main part of the solution is having the canvas drawn before the object that occupies it.

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!

    2 replies

    BenPleysier
    Community Expert
    BenPleysierCommunity ExpertCorrect answer
    Community Expert
    Dec 24, 2017 12:44 AM UTC

    Have a look at

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>Untitled Document</title>

    </head>

    <body>

    <canvas id ="myCanvas" width="400" height="300" style="border:10px solid #000000;"></canvas>

    <script>

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

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

    ctx.beginPath();

    ctx.arc(260,150,100,0, Math.PI*2);

    ctx.fill();

    </script>

    </body>

    </html>

    Where I have used the correct syntax as in "Math.PI" and not made a typo by typing "l" instead of ";".

    The main part of the solution is having the canvas drawn before the object that occupies it.

    Translate
    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Nancy OShea
    Community Expert
    Community Expert
    Dec 23, 2017 9:23 PM UTC

    Is this an Animate CC question?

    Create HTML5 Canvas documents in Animate CC

    Translate
    Nancy O'Shea— Product User & Community Expert