rypinbubs
asked on
Simple javascript not working in Firefox
Can anybody tell me why this simple example works fine in IE, Chrome, Safari, and Opera but not in FireFox?
Thanks!
HTML:
CodeBehind
Thanks!
HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication8.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body id="body">
<script type="text/javascript">
function setHover(id, color) {
if(id != "") {
var buttonName = document.getElementById(id.id);
buttonName.style.backgroundColor = color;
}
}
</script>
<form id="form1" runat="server">
<div id ="test">
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
CodeBehind
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onmouseover", "setHover(window.event.srcElement, 'Red');");
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i agree with kaufmed, this is a job for css not javascript.
ASKER
I agree with kaufmed too, but unfortunately this is just a small part of a bigger problem.
Thanks for the help guys!
Thanks for the help guys!