Skip to content

Instantly share code, notes, and snippets.

@aliharis
Created November 22, 2012 13:45
Show Gist options
  • Save aliharis/4131245 to your computer and use it in GitHub Desktop.
Save aliharis/4131245 to your computer and use it in GitHub Desktop.
/*
** 2/12/2012
** Ali Haris
*/
/*
This is a js which identifies
the viewport width and assigns
to the websites container.
*/
var container = "container";
var width;
// For Modern Web Browsers (Mozilla, Chrome, Opera, Safari)
if (typeof window.innerWidth != 'undefined') {
width = window.innerWidth;
} else if (typeof document.documentElement != 'undefined' && document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
// For IE6 in Compliment Mode
width = document.documentElement.clientWidth;
} else {
// For older version of IE
width = document.getElementsByTagName('body')[0].clientWidth;
}
// Assign the values to Container
viewportAdjust = document.getElementById(container);
viewportAdjust.style.width = ""+width+"px";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment