The Disturbed Buddha

Simple Observations of a Self-proclaimed Novice

Determining a Browser’s Dimensions with Javascript

This is about as cross-browswer compatible as you can get:

<script type="text/javascript"> 
    var winW, winH; 
    if (self.innerWidth) { 
        winW = self.innerWidth; 
        winH = self.innerHeight; 
    } else if (document.documentElement && document.documentElement.clientWidth) { 
        winW = document.documentElement.clientWidth; 
        winH = document.documentElement.clientHeight; 
    } else if (document.body) { 
        winW = document.body.clientWidth; 
        winH = document.body.clientHeight; 
    } 
</script>

January 22, 2008 Posted by | ASP.NET, Javascript, Web Development | Leave a comment