样式Firefox问题

时间:2014-04-24 07:01:59

标签: c# javascript html asp.net firefox

我正在使用下面提到的按钮mouseover事件的代码。此特定代码修复了mouseover事件的文本位置。它适用于Chrome和IE。但不知何故,Firefox似乎存在问题。在Firefox的情况下,位置没有得到修复。

有人可以指导我这是错误的。

<div id="DownloadHelp" runat="server" style="background-color:white; position:fixed; opacity:0; top:100px; z-index:11; color:blue; font-size:small; background-color:silver; border:thin">
    Merge all selected Files
</div>

<asp:button onmouseover="display()" onmouseout="fadeHelp()" id="singleFileDownload" Width="140px" Enabled="false" onclick="SingleFileSelections" runat="server" Text="Merge and Download"></asp:button>

function display() 
{
    document.getElementById("DownloadHelp").style.opacity = "1";
    var x = event.clientX;
    var y = event.clientY;
    document.getElementById("DownloadHelp").style.top = y - 30;
    document.getElementById("DownloadHelp").style.left = x + 10;
}

1 个答案:

答案 0 :(得分:1)

在Firefox中,event对象不会暴露给全局对象。

这样做:

function display(event) 
{
    document.getElementById("DownloadHelp").style.opacity = "1";
    var x = event.clientX;
    var y = event.clientY;
    document.getElementById("DownloadHelp").style.top = y - 30;
    document.getElementById("DownloadHelp").style.left = x + 10;
}

而且:

<asp:button onmouseover="display(event)" onmouseout="fadeHelp()" id="singleFileDownload" Width="140px" Enabled="false" onclick="SingleFileSelections" runat="server" Text="Merge and Download"></asp:button>