# Tuesday, May 02, 2006

IE6 sucks

Wrote a nifty piece of DHTML that does a gallery pop-up in a DHTML div instead of a separate window. I'm sure I saw this in some on-line gallery, and it seems like a great way to do things, now that pop-ups are practically verboten. Nifty, that is, until I pulled it up in IE6. I haven't done a ton of DHTML in years, and clearly I forgot what a pain cross-browser issues are. Until I had to determine the size of the browser:

There are some constants available that give the document area of the window that is available for writing to. These will not be available until after the document has loaded and the method used for referencing them is browser specific. ... This is a little messy because the clientHeight/Width properties can mean different things in different browsers, and even different things in the same browser, depending on whether the document type declaration triggers the browser's strict mode or quirks mode.

[ JavaScript tutorial - Window size and scrolling ]

Ugh. Worst of all, I don't even want to do this from JavaScript, but from CSS. Since Microsoft has been kind enough to provide CSS expressions, I came up with this super-kludge for making the div full size under (what I believe should be) all circumstances:

#id {
    width: 99%;
    height: 99%;
    _width: expression((typeof( window.innerWidth ) == 'number'?window.innerWidth:(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)?document.documentElement.clientWidth:(document.body && ( document.body.clientWidth || document.body.clientHeight ) ?document.body.clientWidth:"100%"))));
    _height: expression((typeof( window.innerHeight ) == 'number'?window.innerHeight:(document.documentElement && ( document.documentElement.clientHeight || document.documentElement.clientHeight)?document.documentElement.clientHeight:(document.body && ( document.body.clientHeight || document.body.clientHeight ) ?document.body.clientHeight:"100%"))));
}

I think this is likely super-over-kill, but it does work. Oh, and why 99%? 100% will pull up scroll bars on the size and bottom in some browsers (IE7b2 for sure...). And why _width? IE6 ignores the _ and treats _width as width (most "real" browsers ignore these rules). And why is the id "id"? It isn't really, but why use my real code without alteration first?

#    Comments [1] |
Tuesday, May 02, 2006 1:12:18 PM (Eastern Standard Time, UTC-05:00)
And to think, people used to laugh at DHTML developers as not doing real programming. We paid our dues.
Comments are closed.