开发者

How to replace content within an Iframe

开发者 https://www.devze.com 2023-04-10 15:46 出处:网络
I have an Iframe on this page and would like to change the text that comes up in the Iframe. Wondering if thi开发者_如何学运维s is possible.

I have an Iframe on this page and would like to change the text that comes up in the Iframe. Wondering if thi开发者_如何学运维s is possible. Aloha, Greg


You can change the text in the iframe if you can pass in URL variables to the iframe. That's probably the easiest way if you can access it.

If you can't edit the code in the iframe, can you please give more details about the setup?


As defined by HTML5 iframe Specs, there are four casess under which you you can access the contents of an iFrame.

A browsing context A is allowed to navigate a second browsing context B if one of the following conditions is true:

  • Either the origin of the active document of A is the same as the
    origin of the active document of B, or
  • The browsing context A is a nested browsing context with a top-level browsing context, and its top-level browsing context is B, or
  • The browsing context B is an auxiliary browsing context and A is
    allowed to navigate B's opener browsing context, or
  • The browsing context B is not a top-level browsing context, but there exists an ancestor browsing context of B whose active document has the same origin as the active document of A (possibly in fact being A itself).

Basically it boils down to the fact that unless the iframe your trying to access is not under the same domain as the parent page, then you wont be able to access it.

0

精彩评论

暂无评论...
验证码 换一张
取 消