Only link A in Firefox cannot simulate A click to trigger its default behavior.

Source: Internet
Author: User

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 ..

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.