when creating web pages I have always used function
var someVariable = document.getElementById('myID');
to get a reference to an element object. It was recently suggested to me that this is not necessary, because there already is such a variable. It's name is equal to the id. I've tested it and it seems to work.
<div id="myID">some text</div>
<a href="someplace" onclick="alert(myID.innerHTML)">click here</a>
This code works and it alerts "some text" as expected. There is just a warning in firefox error console:
element referenced by ID/NAME in global scope. Use WC3 standard document.getElementById() instead....
I am mostly using jQuery by now but I need to prove a point to my boss at work or else I will have have to buy him a box of chocolate :-).
Any ideas why the upper code shouldnt work or why is it a very wrong idea to use it(warning in firefox is not enough)???
Thanks for your answers