Posted By

chrisaiv on 10/18/08


Tagged

resize browser jquery


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

arala22
jamesming
mecha
chrisjlee
Onfire60
alejandrosuch
marcelodornelas
seanpowell
kunaldpatel
ions
tof
ringo380


JQuery: Detecting a Browser Resize


 / Published in: JavaScript
 

This Event Listener + Handler will detect the new height of the browser window.

  1. <script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
  2. <script type="text/javascript" charset="utf-8">
  3. $(document).ready(function(){
  4.  
  5. //If the User resizes the window, adjust the #container height
  6. $(window).bind("resize", resizeWindow);
  7. function resizeWindow( e ) {
  8. var newWindowHeight = $(window).height();
  9. $("#container").css("min-height", newWindowHeight );
  10. }
  11.  
  12. });
  13. </script>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: mrtambourineman on February 26, 2011

Cheers for the snippet, $(window).bind("resize", resizeWindow); is very useful!

Posted By: Snowalker on December 5, 2011

thanks for the snippet! Just a note, min-height may not work in some browsers...

You need to login to post a comment.