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!