WA
11-26-2003, 01:21 AM
Hi:
Just wondering, how do you guys detect the setting for document.compatMode in IE to account for the doctype setting in your scripts? Previously I used the code:
function ietruebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}
//example:
var x=ietruebody().scrollLeft
though just realized this in fact creates problems in IE5.5 and below (since the "compatMode" property doesn't exist in those browsers). I've since figured something like:
function ietruebody(){
return (document.compatMode &&
document.compatMode!="BackCompat")? document.documentElement : document.body
}
//example:
var x=ietruebody().scrollLeft
which should degrade well, though I haven't tested it yet.
Is there any better way to accomplish the above? I was thinking of directly testing for:
document.compatMode=="CSS1Compat"
though am not sure whether "CSS1Compat" might change in IE7, so I thought I'd simply test for "!=BackCompat" instead.
Thanks,
Just wondering, how do you guys detect the setting for document.compatMode in IE to account for the doctype setting in your scripts? Previously I used the code:
function ietruebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}
//example:
var x=ietruebody().scrollLeft
though just realized this in fact creates problems in IE5.5 and below (since the "compatMode" property doesn't exist in those browsers). I've since figured something like:
function ietruebody(){
return (document.compatMode &&
document.compatMode!="BackCompat")? document.documentElement : document.body
}
//example:
var x=ietruebody().scrollLeft
which should degrade well, though I haven't tested it yet.
Is there any better way to accomplish the above? I was thinking of directly testing for:
document.compatMode=="CSS1Compat"
though am not sure whether "CSS1Compat" might change in IE7, so I thought I'd simply test for "!=BackCompat" instead.
Thanks,