Firefox下实现fireEvent


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<select onchange="javascript:alert('a');" id="select1"> <option>1 </option> <option>2 </option> </select>
<INPUT TYPE="button" onclick="ccc()">
<script type="text/javascript">
//<![CDATA[
function ccc(){
var t=document.getElementById('select1')
if( document.all )
{
t.fireEvent(
"onchange" );
}
else
{
var evt = document.createEvent('HTMLEvents');
evt.initEvent(
'change',true,true);
t.dispatchEvent( evt );
}
}

//javascript:document.getElementById('select1').fireEvent('onchange');

//]]>
</script>
</BODY>
</HTML>
posted @ 2010-08-10 22:24  再快一点  阅读(2725)  评论(0编辑  收藏  举报