Re: (window == any_element) always return true in IE6?



David Golightly wrote on 30 aug 2007 in comp.lang.javascript:

Disregarding for a minute the script tag you have outside your HTML
tag (invalid!), this does indeed seem to be true: JScript in IE6 & IE7
seems to have a non-transitive comparison operator. You can try it by
navigating to http://www.google.com on IE and copy/pasting the
following into your address bar:

javascript:var g=document.getElementById('lgpd');alert((window==g)+','+
(g==window));

Now *THAT* is some serious junk code.


Let's keep it simple and compare:

<body>
<script type='text/javascript'>
var g=document.body;
alert((window == g)+','+(g == window));
</script>

and:

<body>
<script type='text/javascript'>
var g=document.body;
alert((window === g)+','+(g === window));
</script>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
.