Ff and IE use different methods to obtain events:
Ie uses window. event, while FF directly uses the parameter event,
<HTML>
<Head>
<Title> IE and Firefox events </title>
</Head>
<SCRIPT type = "text/JavaScript">
Document. onkeydown = function (Event)
{
VaR event = event? Event: window. event;
If (event. keycode = 13)
{
VaR BTN = Document. getelementbyid ("btnlogin ");
BTN. Focus ();
BTN. onclick ();
}
};
</SCRIPT>
<Body>
<Input type = "button" name = "btnlogin" value = "login" onclick = "Return button#onclick () "tabindex =" 3 "id =" btnlogin "class =" button "style =" margin-top: 8px "/>
<Input name = "tbusername" type = "text" id = "tbusername" runat = "server"/>
</Body>
</Html>
<! 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>
<Title> how to obtain the event trigger source (compatible with IE and Firefox) </title>
<Meta name = "generator" content = "editplus"/>
<Meta name = "author" content = ""/>
<Meta name = "keywords" content = ""/>
<Meta name = "Description" content = ""/>
<SCRIPT type = "text/JavaScript">
Function clickme (E)
{
VaR src = e.tar GET | window. event. srcelement;
Alert (SRC. innerhtml );
}
Function clickme2 ()
{
VaR E = arguments [0] | window. event;
VaR src = E. srcelement | e.tar get; // SRC is the trigger source of the event.
Alert (SRC. innerhtml );
}
</SCRIPT>
</Head>
<Body>
<Button onclick = "clickme (event)"> test </button>
<Button onclick = "clickme2 (event)"> Test 2 </button>
</Body>
</Html>