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



On Aug 30, 9:54 am, David Golightly <davig...@xxxxxxxxx> wrote:
On Aug 30, 7:20 am, Fan <fanguo...@xxxxxxxxx> wrote:



test page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//ZH-CN" "http://www.w3.org/TR/html4/strict.dtd";>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title></title>
</head>
<body>
<input type=button id=a onclick=checkme() value=clickme>
</body>
</html>
<script type="text/javascript"><!--
function checkme() {
var a = document.getElementById("a");
alert("window==a? "+(window==a)); //true
alert("a==window? "+(a==window)); //false
}
--></script>
is it a bug of IE?

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 tohttp://www.google.comon 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.

-David

not "non-transitive", "asymmetric". Apologies.

.


Quantcast