The standard event trigger can use the dispatchEvent method. But now FF5 cannot trigger the default behavior of. As follows:
Copy codeThe Code is as follows:
<! Doctype html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Title> Firefox5 link A cannot simulate A click bug </title>
</Head>
<Body>
<A id = "a1" href = "http://mail.sina.com.cn"> Sina mail </a>
</Body>
<Script type = "text/javascript">
Function dispatch (el, type ){
Try {
Var evt = document. createEvent ('event ');
Evt. initEvent (type, true, true );
El. dispatchEvent (evt );
} Catch (e) {alert (e )};
}
Var a1 = document. getElementById ('a1 ');
Dispatch (a1, 'click ');
</Script>
</Html>
Link A to simulate A click using dispatchEvent. The test jumps to mail.sina.com.cn in IE9/Safari/Chrome/Opera. Firefox5 did not jump over.
The click method is added to all elements in Firefox5 (not in Firefox3 ).
Copy codeThe Code is as follows:
<A id = "a1" href = "http://mail.sina.com.cn"> Sina mail </a>
<Script>
Var a1 = document. getElementById ('a1 ');
A1.click ();
</Script>
The test still does not jump to mail.sina.com.cn.
It can be seen that neither of the two methods in Firefox can trigger the default action of link. It may be that the Firefox security mechanism prohibits client programmers from simulating A redirection ..
Note: Use FF3 to test the effect of FF5. Thanks ..