Forum Moderators: open

Message Too Old, No Replies

Reliable IE7/IE8 DOM difference detection?

Anything to use object detection that was added/removed in IE8?

         

JAB Creations

10:34 am on Apr 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've come across an odd bug in the JScript engine that is only present in IE7, but not in IE6 or IE8. When attaching an event to an element such as a click event it will not trigger if the content's area is not used by content and has a transparent (not set so transparent by default) background-color.

So I'm trying to find an object that was added or removed in IE8 so I can reliably apply a JavaScript fix for this. That fix is simply to get the parent element's background-color and apply it.

- John

JAB Creations

11:08 am on Apr 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This page really helped!
[blogs.msdn.com...]

I'm going to use case sensitivity...

if (document.getElementById('Body')) {alert('IE7');} else {alert('IE8');}

...though I will also use object detection for IE7 versus IE8 (such as responseXML in example).

I can use case sensitivity as I practice numerous good coding practices (such as using all lower case code with the only exceptions when JavaScript uses capitol letters in a letter for objects/methods/etc).

- John

Fotiman

1:16 pm on Apr 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That seems like it will be confusing to maintain. That is, it's not obvious what it's doing and in a year someone could look that code and say 'Hey, this is supposed to be "body" not "Body"'.

You could probably use conditional comments.

<!--[if IE 7]><script>var ie7 = true;</script><![endif]-->

[edited by: Fotiman at 1:17 pm (utc) on April 11, 2009]

JAB Creations

1:40 am on Apr 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



True, but I consider good coding practices and a comment for something like that to negate that any way. ;)

- John