- //firefox下js触发click事件:
- <a href="#" onclick= "test1(2)" id= "a3" >hello</a>
- <a href="#" onclick= "test2(1)" id= "b3" >hello2</a>
- <script language="javascript" >
- <!--
- function test1(num)
- {
- window.alert(num);
- }
- function test2(num)
- {
- if (document.all)
- {
- document.getElementByIdx("a3" ).click();
- //document.getElementByIdx("a3").fireEvent("onclick");
- }
- else
- {
- var evt = document.createEvent( "MouseEvents" );
- evt.initEvent("click" , true , true );
- document.getElementByIdx("a3" ).dispatchEvent(evt);
- }
- }
- //-->
- </script>
- void initEvent(String eventTypeArg,
- boolean canBubbleArg,
- boolean cancelableArg)