Internet Explorer 和 onMouseOver/onMouseOut

发布于 2024-09-05 06:10:55 字数 1779 浏览 6 评论 0原文

我尝试在这里寻找类似的问题,但找不到一个,所以它来了:

我有这个html(忽略“+whatever+@”,它在代码隐藏文件中,所以我把一些我从那里得到的变量):

<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>  
            <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>

现在在Firefox,一切都很完美。 div“ScriptContainer”位于整个事物的前面,当鼠标进入或离开时,功能将完全按照其应有的方式工作。 但是 IE8 将文本放在所有内容的前面,然后这些功能就无法像我希望的那样工作。每次鼠标输入位于所有内容前面的文本时,都会调用“ChangeBackcolourOFF”,每次鼠标从文本进入“Scriptcontainer”时都会调用“ChangeBackcolourON”。

所以我要么需要弄清楚如何强制将文本放置在“Scriptcontainer”后面或其他一些解决方案。

我很感激你的回答

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>  
            <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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单身狗的梦 2024-09-12 06:10:58

好吧,我实际上通过反复试验弄清楚了这一点。所以我想我会分享。

显然,如果“Scriptcontainer”没有背景色,则 IE 将文本放在前面,但如果“Scriptcontainer”有背景色,则文本放在后面。

所以我给了“Scriptcontainer”一个背景颜色,并用filter:alpha(opacity = 0);让它看透。不透明度:0;
像这样:

<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+@"()'>

我不确定是否还有其他可能更好的解决方案来解决这个问题,但它似乎对我有用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文