Thursday, September 22, 2011

Find screen resolution using javascript/other language e.g. 1280x1024 ??

I want to find the screen resolution using javascript so that it can load a different image in a CSS script depending on the user's screen resolution. e.g. http://khushman1.googlepages.com/gmaps-i

The pic is a 1024x768 pic, but I have a 1280x1024 resolution, so how do I change the code so that it loads a different picture depending on the user's resolution.

Any other language is also OK but the code should work.Find screen resolution using javascript/other language e.g. 1280x1024 ??
May be this helps you



var windowWidth = 0, windowHeight = 0;

if( typeof( window.innerWidth ) == 'number' ) {

//Non-IE

windowWidth = window.innerWidth;

windowHeight = window.innerHeight;

} else if( document.documentElement %26amp;%26amp; (

document.documentElement.clientWidth ||

document.documentElement.clientHeight ) ) {

//IE 6+ in 'standards compliant mode'

windowWidth = documen0t.documentElement.clientWidth;

windowHeight = document.documentElement.clientHeight;

} else if( document.body %26amp;%26amp; ( document.body.clientWidth ||

document.body.clientHeight ) ) {

//IE 4 compatible

windowWidth = document.body.clientWidth;

windowHeight = document.body.clientHeight;

}Find screen resolution using javascript/other language e.g. 1280x1024 ??
right click on desktop %26gt;%26gt;properties%26gt;%26gt;setting%26gt;%26gt;advance%26gt;%26gt;adapter%26gt;?list modes%26gt;%26gt;choose 1024X768 and apply %26quot;%26quot; ok%26quot;%26quot;