How to Get and operate elements in iframe in JS _ javascript tips-js tutorial

Source: Internet
Author: User
JS obtains and operates the element methods in iframe. For details about how to obtain and set the object elements and documents in iframe in JS, see.

1. Dedicated to IE (Image Positioning through frames index ):

The Code is as follows:


Document.framespolici}.doc ument. getElementById ('element id ');

2. Dedicated to IE (Image Positioning through iframe ):

The Code is as follows:


Document.frames{'iframe's name'}.doc ument. getElementById ('element id ');

The above method is not only applicable to iframe, but also to frame in frameset. Although IE is good at customizing standards, I have to say that many of its designs are more humane. For example, it also supports the following standard paths and provides a simple and visualized writing method.

3. Common Methods:

The Code is as follows:


Document.getelementbyid('iframe's id'{.content}doc ument. getElementById ('element id ')

Note that contentWindow is often ignored because it represents the window objects inside the frame and iframe.

JS get iframe document content

The Code is as follows:


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.