Firefox does not support the click method.

Source: Internet
Author: User

<A href = "javascript: Alert ('click')" id = "start"> click me </a>
<A href = "javascript: Document. getelementbyid ('start'). Click ()"> click Start </a>

The above process can be executed in IE, but cannot be executed in Firefox.

Only input elements can be assigned according to W3C standard click method.

Reference: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-6043025

Refer to the online method:

Function invokeclick (element ){
If (element. Click) element. Click ();
Else if (element. fireevent) element. fireevent ('onclick ');
Else if (document. createevent ){
VaR EVT = Document. createevent ("mouseevents ");
EVT. initevent ("click", true, true );
Element. dispatchevent (EVT );
}
}

 

NOTE 1: In Firefox, non-input elements still do not work.

NOTE 2: In IE8, the click method is executed on the <input type = File> File Upload control. Only the code bound to The onclick event of this element can be executed, the file selection dialog box does not pop up.

========================================================== ========================================================== ======
Void initevent (string eventtypearg, Boolean canbubblearg, Boolean cancelablearg)
The initevent method is used to initialize the value of the event created through the deleentevent interface. This method can only be called before the event is assigned through the dispatchevent method, although it can be called multiple times at this stage (if necessary ). If it is called multiple times, the last call takes precedence. If it is called from the subclass of the event interface, only the value specified in the initevent method is modified, and all other attributes remain unchanged.
Parameters:
Eventtypearg-specifies the event type. This type can be any event type defined in this specification or a new event type. The string must be an XML name. Any new event type must not start with an uppercase, lowercase, or mixed-case version of the string "dom. This prefix is reserved for future DOM Event sets. We strongly recommend that third parties who add their own events use their own prefixes to avoid confusion and reduce the possibility of conflicts with other new events.
Canbubblearg-specifies whether the event can be bubble.
Cancelablearg-specifies whether the default action of the event can be blocked.

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.