Internet Explorer and onMouseOver/onMouseOut
I have tried looking a similar question on here but couldnt find one so here it comes:
I have this html (ignore the "+whatever+@", its in a codebehind file so im putting some variables that im getting from there):
<div id='ReferenceContainer"+UniqueID+@"' style='background-color:"+BackcolourOFF+@"; width:"+CompWidth+@"; height:"+CompHeight+@";'>
<div id='Reference"+UniqueID+@"' style='width:"+CompWidth+@"; height:"+CompHeight+@"; '>
<div id='RefTextContainer"+UniqueID+@"' style='float:left; width:"+CompWidth+@"; height:"+CompHeight+@"; ' >
<div id='RefTitleCon' style='margin-top:"+RefTitleMargin+@"px; color:"+RefTitleColor+@"; z-index:-1;' ><p><b>"+RefTitle+@"</b></p> </div>
开发者_Python百科 <div id='RefTextCon'><p>"+RefText+@"</p></div>
</div>
<div id='RefPicContainer"+UniqueID+@"' style='float:right;'>
<img id='RefImg"+UniqueID+@"first' class='first' name='RefImg"+UniqueID+@"' src=" + StartImg + @" style='position:absolute;' ></img>
<img id='RefImg"+UniqueID+@"second' class='second' name='RefImg"+UniqueID+@"' src=" + AltImg + @" style='display:none;' ></img>
</div>
</div>
<div id='ScriptContainer"+UniqueID+@"' style='width:"+CompWidth+@"; height:"+CompHeight+@"; position:relative; top:-"+CompHeight+@"px; left:0px;' onMouseOver='ChangeBackcolourON"+UniqueID+@"()' onMouseOut='ChangeBackcolourOFF"+UniqueID+@"()'></div>
</div>
Now in firefox, everything works just perfect. The div "ScriptContainer" sits in front of the whole thing and when the mouse enters or leaves the functions work exactly as they should. But IE8 places the text in front of everything and then the functions do not work as i would like them to. "ChangeBackcolourOFF" gets called every time the mouse enters the text, which sits in front of everything and "ChangeBackcolourON" gets called every time the mouse enters the "Scriptcontainer" from the text.
So i either need to figure out how to force the text to be placed behind the "Scriptcontainer" or some other solutions.
I appreciate you answers
Okay, i actually figure this out by trial and error. So i thought i would share.
Apparently, if the "Scriptcontainer" does not have a background colour then IE places the text in front, but if the "Scriptcontainer" has a background colour then the text is placed behind.
So i gave the "Scriptcontainer" a background colour and made it see through with filter:alpha(opacity = 0); opacity: 0; so like this:
<div id='ScriptContainer"+UniqueID+@"' style='width:"+CompWidth+@"; height:"+CompHeight+@"; position:relative; background-color:#ffffff; filter:alpha(opacity = 0); opacity: 0;' onMouseOver='ChangeBackcolourON"+UniqueID+@"()' onMouseOut='ChangeBackcolourOFF"+UniqueID+@"()'>
Im not sure if there are other, perhaps better solutions to this problem but it seems to work for me.
精彩评论