Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda