2

Possible Duplicate:
IE/Chrome: are DOM tree elements global variables here?
Element accessible with ID

I tried this code that is not expected to work:

<html> 
<head>
<script>
function change() {
    alert("changing !!"+dummy);
    dummy.innerHTML="hello !!";
}
</script>
</head>
<body>
    <div id="dummy" onclick="change();" > nothing good here !! </div>
</body>
</html>

And it seems to work fine (ff16, ie8, chrome) while dummy is not initialized like it should be via a document.getElementByID('dummy'); is this a html5 feature or just a edge effect?

Community
  • 1
  • 1
user1754385
  • 79
  • 1
  • 2

1 Answers1

1

Now All browser create global variable for each id present in dom. See my Question

dummy == document.getElemetById('dummy') // true
Community
  • 1
  • 1
Anoop
  • 23,044
  • 10
  • 62
  • 76
  • 1
    Shouldn't you vote to close this question as a duplicate of yours then? Seems to be exactly the same question... – Felix Kling Oct 17 '12 at 20:20