Link to home
Start Free TrialLog in
Avatar of Imaginx
Imaginx

asked on

Trying to find a cross broswer solution to find either the screen resolution or browser resolution.

$(window).width();   // returns width of browser viewport
$(document).width(); // returns width of HTML documentI have a php site that needs to know the screen resolution OR the browser resolution to correctly place an absolute position <div></div>

The OS's are OSX 10.6, WinXp Pro, Win 7 Pro
Browsers are IE6,IE7,IE8,IE9,Safari>5,misc firefox ..

I can get document.width/document.height to work in safari.
I can't get it to work in IE

I can get mild success with the jquery library in IE, but not safari
(http://api.jquery.com/width/ :::
$(window).width();   // returns width of browser viewport
$(document).width(); // returns width of HTML document
)

What works all over the place ??
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

I don't think there is a cross browser solution sorry. At least I have never seen one. That's why you should use a conditional query to see which browser is being used, then set the right code depending on what browser they have.

<!--[if IE 6]>
// put IE6 code in here
<![endif]-->
and so on for all the other browsers.
ASKER CERTIFIED SOLUTION
Avatar of Pieter Marais
Pieter Marais
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial