Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
I've tried setting up my Canvas in JavaScript and it isn't working

I've restarted about 5 times and it's not working. I'm trying to set up my canvas. The first part is the code in the js file and the second code is what I put in the HTML file.

JS:

var canvas;
var ctx;
var w = 1000;
var h = 600;


function setUpCanvas(){
    canvas = document.querySelector("#myCanvas");
    ctx = canvas.getContext("2d");
    canvas.width = w;
    canvas.height = h;
    canvas.style.border = "5px dotted orange";
   

HTML:

 <!DOCTYPE html>
<html>
    <head>
        <link rel ="stylesheet" type = "text/css" href = "m4.css">
    </head>
    <body>
        <div id = "container">
            <h1> module 4 : arrays and loops</h1>
            <canvas id = "myCanvas"></canvas>
        </div>
        <script src = "m4.js"></script>
    </body>
</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simple answer, it works. for proof, visit

https://loading.hermanboxcar5.repl.co

ok if you do ctrl u on that website it will give you the code you did (except my js file is named script.js). My best guess so far is after the last line of your js put a }

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!