Skip to content

Instantly share code, notes, and snippets.

@TLMcode
Created April 11, 2017 06:09
Show Gist options
  • Select an option

  • Save TLMcode/ea4c7182156b76f2c92a2979993f2eaf to your computer and use it in GitHub Desktop.

Select an option

Save TLMcode/ea4c7182156b76f2c92a2979993f2eaf to your computer and use it in GitHub Desktop.
Private anon init function for returning a client view port dimensions array.
GetViewportDimension: function()
{
var ViewPortArr = [];
// Standards compliant client
if ( typeof window.innerWidth != 'undefined' )
{
ViewPortArr.Width = window.innerWidth
ViewPortArr.Height = window.innerHeight
} // IE6 compliant mode
else if ( typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0 )
{
ViewPortArr.Width = document.documentElement.clientWidth
ViewPortArr.Height = document.documentElement.clientHeight
} // IE6 older, other
else
{
ViewPortArr.Width = document.getElementsByTagName( 'body' )[0].clientWidth
ViewPortArr.Height = document.getElementsByTagName( 'body' )[0].clientHeight
}
return ViewPortArr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment