Good day! I am confused about why this works the way it does. If you load
the following page (on IE5) and roll your mouse over the "test text", you
should get two successive dialg boxes. The first will show the 'value' of
the onmouseover handler, and the second shows the color value passed to
the menuOver function. What has me stumped is how the color value
of "#222222" is passed to the menuOver function, when it appears that the
handler is passing what should now be an undefined variable (sNewColor).
It seems the first dialog box should return something like "function()
{menuOver(this,'#222222');", but in order to make that happen I would have
to write something like "onmouseover=function()(menuover(this,eval
(sNewColor)));" but of course that does not work.. Is there a better or
different way to assign the event handler?
Thanks for your patience..
Chris Herring
here is the code (probably only works on IE 5.5..)
<html>
<head>
<script>
function startup(){
addMenu('testMenu','#222222');
}
function addMenu(sId,sNewColor){
var oDivShell=document.createElement('div');
with (oDivShell){
id=sId;
innerHTML='test text';
onmouseover=function(){menuOver(this,sNewColor)};
}
document.body.appendChild(oDivShell);
}
function menuOver(oMe,sColor){
alert(oMe.onmouseover);
alert(sColor);
}
</script>
</head>
<body onload="startup();"style="background-color:white">
</body>
</html>