An example of Solutions to "Access Denied" when using IFRAME for document objects

Source: Internet
Author: User
Webpage: a.html B .html
Link: add an iframein the.html page, and its srcamedirects to B .html.
Problem: the "Access Denied" script error will be reported when using the assumument. If you use the round-robin method to access the document, the same error will be reported several times at the beginning, and then it will be displayed and operated properly.

Reason excluded:
1. The two pages belong to the resource file of the same site, without cross-origin access, and the two pages belong to the same domain, that is, the document. domain attributes are consistent.
The IFRAME in 22.16a.html page does not affect the error in both dynamic creation and fixed generation on the webpage. The only difference is that when detecting the loading status of IFRAME, the status order of dynamic creation is uninitialized-> loading-> loaded-> interactive-> complete, the status order of a fixed generation is complete-> loading-> loaded-> interactive-> complete.

Analysis:
After the IFRAME is loaded in the completed state, it can normally access and modify the document object whose SRC points, it indicates that the process of loading IFRAME to the parent page is still unable to access the Document Object introduced by IFRAME, or the IFRAME may not be fully loaded when the parent page is displayed, therefore, an error message indicating Access Denied is displayed.

Modify the script comments:
If the ID of the IFRAME in the hypothetical a.html page is named IFR, you need to adjustCodeOnly one
If (document. readystate = "complete" & IFR. readystate = "complete "){
// Access and operate the Document Object introduced by IFRAME here
}

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.