日期:2014-05-16  浏览次数:20390 次

关于click的问题
onclick是好用。。可是怎么触发它的click事件呢?
<input   id= "wc_1 "   type= "file "   />
<script   type= "text/javascript ">
var   $   =   function   (id)   {
return   document.getElementById(id);
};
window.onload   =   function   ()   {
var   t   =   $( "wc_1 ");
if   (!document.createEvent)   t.click();
else   {
//var   e   =   t.ownerDocument.createEvent( "MouseEvents ");
var   e   =   document.createEvent( "MouseEvents ");
e.initEvent( "click ",   false,   true);
t.dispatchEvent(e);
}
}
</script>

------解决方案--------------------
object.fireEvent( "onclick ");
------解决方案--------------------
<input id= "aa " type=button onclick= "alert( 'aaaa ') ">
<script>
var a=document.getElementById( "aa ");
aa.click();
</script>
FF下,没问题啊