Equivalent of window.innerWidth/Height in IE

IE 8 continues to defy pupolar JavaScript functions in Firefox and Chrome, for window/document measurements.

The equivalent of window.innerWidth/Height in IE is document.documentElement.clientWidth/Height.

Following codes can be used:

; var horizonPosi = (window.innerWidth) ? window.innerWidth : document.documentElement.clientWidth
; var verticalPosi = (window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight

There are other functions such as document.body.clientWidth/Height, document.body.offsetWidth/Height, but none of them are the equavalent. There is also a special case for document.body.clientHeight: it does not work while document.body.clientWidth works fine.

No comments:

Post a Comment

Labels