About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).

Wednesday, January 30, 2013

Quick Note: Resize canvas to browser

Resize canvas to browser's width/height (at least in IE9+), using jQuery:

Code Snippet
  1. <canvas id="myCanvas" width="1600px" height="1200px" style="border: 1px solid #d3d3d3;">Your browser does not support the HTML5 canvas tag.
  2. </canvas>
  3.  
  4. <script type="text/javascript">
  5.     function resizeFrame() {var h = $(window).height();var w = $(window).width();$("#myCanvas").css('height', h - 100); $("#myCanvas").css('width', w - 50);}
  6.  
  7.     $(document).ready(function () {
  8.         jQuery.event.add(window, "load", resizeFrame);
  9.         jQuery.event.add(window, "resize", resizeFrame);
  10.     });
  11.  
  12.     
  13. </script>



No comments: