Skip to content

Instantly share code, notes, and snippets.

@russ
Created April 29, 2013 22:27
Show Gist options
  • Save russ/5485313 to your computer and use it in GitHub Desktop.
Save russ/5485313 to your computer and use it in GitHub Desktop.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<style>
#bg-left-extension {
width: 1000px;
background: blue;
}
</style>
<div id="bg-left-extension" height="100"></div>
<script>
function getWindowSize() {
var w = 0, h = 0;
if(typeof(window.innerWidth ) == 'number' ){
w = window.innerWidth;
h = window.innerHeight;
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
w = document.body.clientWidth;
h = document.body.clientHeight;
}
return {width: w, height: h};
}
$(document).ready(function() {
size = getWindowSize();
$("#bg-left-extension").css('height', size.height);
});
$(window).resize(function() {
size = getWindowSize();
$("#bg-left-extension").css('height', size.height);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment