I'm trying to get a canvas element to take up the entirety of the document height and window width, so that when I resize the window, the canvas element stretches with it, in effect, giving me a full screen canvas. What is actually happening, though, is the document height(and consequently, the canvas height) increases no matter how the window is resized.
I'm using this code:
$(document).ready(function () {
$("#wrapper").before("<div id='background'><canvas id='depth' width='"+$(window).width()+"'height='"+$(document).height()+"'></canvas></div>");
$(window).resize(function() {
$("#depth").attr("width",$(window).width());
$("#depth").attr("height",$(document).height());
});
});
I've also tried using DOM scripting with the exact same result. Is this a quirk of resizing canvas elements, or am I missing something?