I have quite an odd question. Usually I ask whenever javascript is not
acting the way I'd expect. This time I'm trying to figure out why
something works when I don't think it should be working!
I'm working on a web page that has a <div> area for dynamic content
display (id='content').
In between the </body> and </html> tags is where I'm storing the text
to be displayed when needed. They are stored inside wrapper <div>s
which are set to "display:none" (<div id='wrap1' class='cloak'> etc.)
I change the content displayed thusly:
onclick="content.innerHTML=wrap1.innerHTML"
I don't understand why this works, because *nowhere* in my document
have I declared:
var content=document.getElementById('content')
I *should* be using:
onclick="getElementById('content').innerHTML=getEl ementById('wrap1').innerHTML"
Shouldn't I? In fact, that is the way I originally started doing it.
Then I started using variables so that I could remove some of the
"getElementById"s and by fluke I discovered it wasn't necessary to set
the variables. I've even rebooted in case there was some memory leak
keeping those variables set even after I've removed their declaration
from my script, but it still continues to work. Why is it working? Is
this a hidden feature of IE? Or have I missed something obvious?
Lance