In ie, the IFRAME of document. createelement cannot be set.

Source: Internet
Author: User

The IFRAME name can be the target of the link or form, and the link or form can be opened to the IFRAME.
I have encountered a problem in IE that I cannot set the IFRAME name attribute.

JavascriptCode

VaR IFRAME = Document. createelement ('iframe ');
IFRAME. Name = 'ifr ';
// IFRAME. setattribute ('name', 'ifr'); // No.

Neither of the above methods can be set. Later, we found that we could also create it like this.

JavaScript code

VaR IFRAME = Document. createelement ('<IFRAME name = "IFR"> </iframe> ');
In this way, there is no problem in IE, but this method cannot be passed in Firefox. So last

JavaScript code

Try {
VaR IFRAME = Document. createelement ('<IFRAME name = "IFR"> </iframe> ');
} Catch (e ){
VaR IFRAME = Document. createelement ('iframe ');
IFRAME. Name = 'ifr ';
}

In this way, it is compatible.


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.