Return to Snippet

Revision: 12449
at March 15, 2009 14:45 by ShiftyP


Initial Code
browser : {
		IE : !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1),
		Opera : navigator.userAgent.indexOf('Opera') > -1,
		WebKit : navigator.userAgent.indexOf('AppleWebKit/') > -1,
		Gecko : navigator.userAgent.indexOf('Gecko') > -1 
				&& navigator.userAgent.indexOf('KHTML') === -1,
		
		getViewHgt : function(){
			return browser.IE ? 
					// IE Cases
					// Test for IE 5-7 Quirks and IE 4
					(!(document.documentElement.clientHeight) 
					|| (document.documentElement.clientHeight === 0)) ?
					// IE 5-7 Quirks and IE 4 case
					document.body.clientHeight : 
					//IE 6+ Strict Case
					document.documentElement.clientHeight:
					// Gecko and Other DOM compliant case
					window.innerHeight; 
		},
		
		getViewWdth : function(){
			return browser.IE ? 
					// IE Cases
					// Test for IE 5-7 Quirks and IE 4
					(!(document.documentElement.clientWidth) 
					|| (document.documentElement.clientWidth === 0)) ?
					// IE 5-7 Quirks and IE 4 case
					document.body.clientWidth : 
					//IE 6+ Strict Case
					document.documentElement.clientWidth:
					// Gecko and Other DOM compliant case
					window.innerWidth;
		}

Initial URL

                                

Initial Description
A little bit of browser detection and some functions to get the viewport height and width, crossbrowser.

Initial Title
Find Viewport Height / Width, crossbrowser:

Initial Tags
ie, DOM

Initial Language
JavaScript