don't ever do browser sniffing if you want actually do object detection. 
furthermore I wouldn't automatically assume that there is 
document.documentElement (IE in Standards Mode only!)...


My proposal:

$.clientCoords = function() {
     var dimensions = {width: 0, height: 0};
     if (document.documentElement) {
         dimensions.width = document.documentElement.offsetWidth;
         dimensions.height = document.documentElement.offsetHeight;
     } else if (window.innerWidth && window.innerHeight) {
         dimensions.width = window.innerWidth;
         dimensions.height = window.innerHeight;
     }
     return dimensions;
}



Regards, Klaus



limodou schrieb:
> On 9/16/06, limodou <[EMAIL PROTECTED]> wrote:
>> I want to implement center() effect, but I don't know how to get the
>> correct widht and height of the browser client. I googled and found
>> that in (FF) I should use windows.innerHeight and window.innerWidth,
>> but in msie I could use document.documentElement.clientWidth and
>> document.documentElement.clientHeight.
>>
>> I want to know is jQuery has a shortcut function to get that? I write
>> a simple function to do that:
>>
>> $.clientCoords = function(){
>>     if(window.innerHeight || window.innerWidth){
>>         return {w:window.innerWidth, h:window.innerHeight}
>>     }
>>     return {
>>         w:document.documentElement.clientWidth,
>>         h:document.documentElement.clientHeight
>>     }
>> }
>>
>>
> It seems that clientWidth, clientHeight not correct, so I changed to
> offsetWidth and offsetHeight, so the code should be:
> 
> $.clientCoords = function(){
>     if(jQuery.browser.msie){
>         return {
>             w:document.documentElement.offsetWidth,
>             h:document.documentElement.offsetHeight
>         }
>     }
>     else
>         return {w:window.innerWidth, h:window.innerHeight}
> }
> 
> 
> 

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to