Created
November 22, 2012 13:45
-
-
Save aliharis/4131245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** 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