I am writing a simple javascript code to capture which element raised an event. When I run this code it works okay in IE. But Firefox says ‘event’ not defined.
Also I am using Microsoft Visual studio 2008 to create this file. And for somereason, there is no context sensitive help when I am using event object. Why is that?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Javascript_CreateaDynamicTable.aspx.cs" Inherits="FHLBSF.QRMDMS.WebUI.Javascript_CreateaDynamicTable" %>
<!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>
<form id="form1" runat="server">
<div>
<img alt="" src="media/fhlbsflogo.gif" />
<p style="position:absolute;top:10;left:10;color:black" onmouseout="OnMouseOut()" onmouseover="OnMouseoverEventHandler()"> Demo of "OnMouseOver" handler</p>
<table border="1">
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tfoot id="tfootelement" onmousemove="WhichElementIsThis();">
<tr>
<td id="tdSum" onclick="WhichElementIsThis();" >Sum</td>
<td>$180</td>
</tr>
</tfoot>
<tbody>
<tr >
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
</table>
</div>
</form>
</body>
<script type="text/javascript" language="javascript">
function WhichElementIsThis() {
var varElementId = event.srcElement.id;
alert(varElementId);
}
</script>
</html>