Skip to content

Instantly share code, notes, and snippets.

@jennschiffer
Created March 12, 2013 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jennschiffer/5140138 to your computer and use it in GitHub Desktop.
Save jennschiffer/5140138 to your computer and use it in GitHub Desktop.
a canvas that fills the whole browser window
$(document).ready(function(){
// create canvas the size of the window
var canvasHeight = $(window).height();
var canvasWidth = $(window).width();
$('body').prepend('<canvas id="canvas" width="'+ canvasWidth +'" height="'+ canvasHeight + '" style="cursor:crosshair;">Your browser doesn\'t support canvas. Boo-hiss.</canvas>');
// resize canvas if window size changes - I particularly don't like this, but whatevs floats yo boats...
$(window).resize(function() {
var canvasHeight = $(window).height();
var canvasWidth = $(window).width();
$('#canvas').attr('width', canvasWidth).attr('height', canvasHeight);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment