I am using a file called pngbehavior.htc to get png files (images with alpha level transparency) with rollovers utilizing src switching to work in IE. The problem was every third or fourth mouse over IE would crash with some mysterious error. I decided that instead of switching the source on Mouse Out and Over, I would over lay the images in spans, and use onMouseOut and Over to switch the css display of the overlaying spans to block and none, respectively, to preform the rollover effect. This solved my problem, but now it is really easy to move the mouse too fast and have the previous onMouseEvent event not fire when the mouse leaves the parent div. I am fairly javascript literate, but I am still a bit mystified by the cross-browser complications of event propagation. This problem happens in both IE and Firefox, so it don't think it's that. Is the next onMouseOver event canceling out the other onMouseOut Event? Is there a way to fix this using the current setup (Some of the third party code I am using specifically takes control of events, releasing and firing them manually). Is there a like workable solution for this (these will based on dynamically generated code, either in hidden form variables or javascript functions) or will I have to try and find another solution?
Here is the code:
Thanks!
Here is the code:
Code:
function swapDisplay(obj1,obj2){
if (obj1.style.display == 'block' || obj2.style.display == ''){
obj1.style.display = 'none';
obj2.style.display = 'block';
}else{
obj2.style.display = 'none';
obj1.style.display = 'block';
}
}
<div class="button_DIV" onClick="dostuff();">
<span id="button_off" class="button_SPAN_off" onMouseOver="swapDisplay(this,document.getElementById('button_on'));">
<img class="button_IMG" border="0" src="/images/button_off.png">
</span>
<span id="button_on" class="button_SPAN_on" onMouseOut="swapDisplay(this,document.getElementById('button_off'));">
<img class="button_IMG" border="0" src="/images/button_on.png" alt="Button">
</span>
</div>
Thanks!