我正在使用javascript来更改鼠标悬停上的一些asp按钮设置。它在IE中工作。但不适用于Firefox。有没有其他的JavaScript代码可以支持几乎所有的浏览器?我的代码如下Windows.event是未定义的 - 在Firefox中的JavaScript错误
<script type="text/javascript">
var previousColor;
function Changecolor() {
previousColor = window.event.srcElement.style.backgroundColor;
window.event.srcElement.style.backgroundColor = "Blue";
window.event.srcElement.style.cursor = "hand";
}
function RestoreColor() {
window.event.srcElement.style.backgroundColor = previousColor;
}
</script>
<asp:Button ID="btnSearch" runat="server" BackColor="#800000" Font-Bold="True" Font-Names="Arial" onmouseover="Changecolor();" onmouseout="RestoreColor();" ForeColor="White" Height="28px" OnClick="btnSearch_Click2" Text="Search Jobz" Width="117px" />
你为什么这么难?只需使用CSS。 – ZippyV 2010-01-22 09:24:56
事实上,对于这种事情,CSS是更好的选择,尽管':hover'在IE6中无效,没有[whatever:hover](http://www.xs4all.nl/~peterned/csshover.html) – 2010-01-22 09:31:38