When accessing elements using window.someThing, "someThing" should be the name of the html element. But now I see that I can access the element by id in the same way, without document.getElementById. When was this changed? It seems to work in Chrome, IE, Firefox 13, but not in Firefox 12.
For example:
<div id="MyDiv">Content</div> <script> MyDiv.innerHTML = "New Content"; </script>
Why does the above example work? Why I should not do:
var MyDiv = document.getElementById('MyDiv');
Is this something new, or was it always possible, and I just did not know about it?
javascript html
Alex dn
source share