AJAX getWidth()- and getHeight()-blues

handgestrickt wanted to cover the complete content of a browser window with a fading layer. so we needed to know how the width and height of the document.body. in all browsers using Prototype.js and document.body.getWidth() and document.body.getHeight() did a good job. guess in which browser not? bingo! M$ Internet Exploiter 7. isn't it strange that most JavaScript-code contains tons of workarounds for Internet Explorer and Safari. maybe we all need some holidays in a country where the sun is shining. here is another workaround:

var foo = {
        winWidth: function() { return document.body.offsetWidth || window.innerWidth || document.documentElement.clientWidth || 0; },
        winHeight: function() { return document.body.offsetHeight || window.innerHeight || document.documentElement.clientHeight || 0; }
}

Sunday, 18. March 2007 • trackback url

Add Comment

( to reply to a comment, click the reply link next to the comment )

Comment Title:
Your Name:
Email Address:
Make Public?
Website:
Make Public?

Comment:


Allowed XHTML tags : a, b, i, strong, code, acrynom, blockquote, abbr. Linebreaks will be converted automatically.


Captcha:

captcha image

please type the content of the above image into the following form-field: