0

I'm trying to draw a background with the <canvas> tag and Javascript. However, I keep running into this error: TypeError: background is null

My canvas tagged is assigned to bgCanvas. Full script can be found here: https://codepen.io/loktar00/pen/uEJKl

HTML:

<canvas id="bgCanvas"></canvas>

Javascript:

var background = document.getElementById("bgCanvas"),
    bgCtx = background.getContext("2d"),
    width = window.innerWidth,
    height = document.body.offsetHeight;

I wish to use this script as a background for a website. All help is appreciated!

narypigeon
  • 103
  • 9
  • Going to your link, there appears to be no such error. – CertainPerformance May 30 '19 at 07:22
  • This is rather a duplicate of [Why does jQuery or a DOM method such as getElementById not find the element?](https://stackoverflow.com/questions/14028959/why-does-jquery-or-a-dom-method-such-as-getelementbyid-not-find-the-element) – Chris G May 30 '19 at 07:29

0 Answers0