Ok, this is quite a complicated issue that I am having here, at least I think. I have a javascript function called setMouseovers, that iterates through a loop, and adds mouseover event handlers to items on the page, based on id. Initially I was using element.setAttribute(‘onmouseover’, ‘do-something’) which worked great in ff, but does nothing in ie – see this link: [URL=”http://webbugtrack.blogspot.com/2007/08/bug-242-setattribute-doesnt-always-work.html”]http://webbugtrack.blogspot.com/2007/08/bug-242-setattribute-doesnt-always-work.html
Anyways, I was forced to use the .onmouseover property to dynamically set onmouseover methods. Here is the resulting code:
[code=html]
<html>
<head>
<style type=”text/css”>
div
{
width: 100px;
border: 1px solid #000;
}
</style>
<script type=”text/javascript”>
function setMouseOvers()
{
for (var i=1;i<9;i++){
var div = document.getElementById(‘div’ + i);
div.onmouseover = function(){alert(i);};
}
}
window.onload = setMouseOvers;
</script>
</head>
<body>
<div id=”div1″> div #1 </div>
<div id=”div2″> div #2 </div>
<div id=”div3″> div #3 </div>
<div id=”div4″> div #4 </div>
<div id=”div5″> div #5 </div>
<div id=”div6″> div #6 </div>
<div id=”div7″> div #7 </div>
<div id=”div8″> div #8 </div>
</body>
</html>
The problem is that, the alert is alerting the user with the value of i at the time the div is moused over, as opposed to the time that the onmouseover function is being created, and I would like the opposite. If you don’t understand what I mean, copy the above html into notepad and play around. Any help is appreciated here. Thanks.