Compile Scripting-javascript skills compatible with IE and FireFox

Source: Internet
Author: User
Writing scripts compatible with IE and FireFox is annoying. Today I 've experienced it again. I. formal expressions
Try to use the following expression to extract the content after the brackets "]" and call the following code in IE normally. FireFox will always replace the content of the double data row with the content of the singular line.
(/(\]) ([^-}] *)/Ig1_.exe c (srcText );
Newtext = "[Department]" + RegExp. $2;
It is confirmed that the problem lies in the "g" of "ig". FireFox treats RegExp as a global variable and does not update $2 in time.
2. Remove Select entries
IE supports select. options. remove (index), while FireFox supports select. remove (index). The compatible method is select. options [I] = null;
3. showModalDialog
FireFox can use showModalDialog. However, if the showModalDialog page has a frame set, the window. dialogArguments for the frame page can be used successfully. FireFox cannot use window. parent. dialogArguments.
Iv. childNodes
FF does not have children. It must be compatible with childNodes, but IE and FF are different. FF regards blank text and line breaks as nodes. To avoid correct nodes obtained by childNodes (index, do not use spaces or line breaks between HTML identifiers.
5. removeChild
FF and node. removeNode (true) cannot be changed to node. parentNode. removeChild (node ).
Vi. outerHTML
FF has no node. outerHTML, when you call node. parentNode. innerHTML is used for special processing. If you only add an event response or set a property value, you can directly add an element. onclick = function () {callxxx (x, y );}
VII. script domain Problems
The cause of this problem is unknown, FF is used

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.