简体   繁体   中英

Why does this onMouseOut event not fire in Firefox?

I've seen this issue before but have found no concrete answers so far. I have an onmouseout event which works in practically everything but Firefox. It's not even showing up in Firebug, which makes no sense at all.

Here are the offending lines of code:

<div id="MarketBox3" class="MarketBox" style="top: 205px;">
<div id="TimeBox3Cont" class="TimeBox"><h3 ifirefoxd="TimeBox3" style="color: white; text-     shadow: 0px 0px 5px #000; letter-spacing: 1px; font-size: 12px;"></h3></div>
<div id="TimeBar3" class="TimeBar" style="left: 300px; width: 300px;" onmouseover="CheckOpen(3)" onmouseout="document.getElementById('intext3').innerText = 'bla bla'">
<div id="MarketName3" class="MarketName">
<div id="inbox3" style="position: absolute; top: -2px; height: 30px; width: 300px;">
<h3 id="intext3" style="color: white; text-shadow: 0px 0px 2px #000; letter-spacing: 1px; font-size: 16px;">Frankfurt - Germany</h3>
</div>
</div>
</div>
</div>

Can anyone have a crack at what's going on? It literally works fine in everything except Firefox.

This works just fine:

<div id="MarketBox3" class="MarketBox" style="top: 205px;">
<div id="TimeBox3Cont" class="TimeBox"><h3 id="TimeBox3" style="color: white; text-     shadow: 0px 0px 5px #000; letter-spacing: 1px; font-size: 12px;"></h3></div>
<div id="TimeBar3" class="TimeBar" style="left: 300px; width: 300px;" onmouseover="document.getElementById('intext3').innerText = '111'" onmouseout="document.getElementById('intext3').innerText = 'bla bla'">
<div id="MarketName3" class="MarketName">
<div id="inbox3" style="position: absolute; top: -2px; height: 30px; width: 300px;">
<h3 id="intext3" style="color: white; text-shadow: 0px 0px 2px #000; letter-spacing: 1px; font-size: 16px;">Frankfurt - Germany</h3>
</div>
</div>
</div>
</div>

Demo on JS Fiddle .

There might be a problem with your CheckOpen() function,

Try

onmouseover="alert(1)"

onmouseout="alert(2)"

instead of

onmouseover="CheckOpen(3)"

Another Suggestion

It seems that Firefox treats innerText differently than other browsers .

Using a javascript library will erase this problem because it will automatically take care of differences in browser behavior.

I tried using jQuery and it works fine.

<div id="MarketBox3" class="MarketBox" style="top: 205px;">
<div id="TimeBox3Cont" class="TimeBox"><h3 id="TimeBox3" style="color: white; text-     shadow: 0px 0px 5px #000; letter-spacing: 1px; font-size: 12px;"></h3></div>
<div id="TimeBar3" class="TimeBar" style="left: 300px; width: 300px;" onmouseover="javasript:function f(){ $('#intext3').text('bla bla');} f(); " onmouseout="javasript:function g(){ $('#intext3').text('1111');} g(); ">
<div id="MarketName3" class="MarketName">
<div id="inbox3" style="position: absolute; top: -2px; height: 30px; width: 300px;">
<h3 id="intext3" style="color: white; text-shadow: 0px 0px 2px #000; letter-spacing: 1px; font-size: 16px;">Frankfurt - Germany</h3>
</div>
</div>
</div>
</div>

Demo on JS Fiddle .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM