簡體   English   中英

如果iframe元素本身可見或不可見,iframe內的頁面能否“看到”跨域?

[英]Can a page inside an iframe “see” cross domain if the iframe element itself is visible or not?

如果我從其他域的iframe中加載頁面,所包含的頁面是否仍然可以查看iframe元素或其父元素是否可見(例如,使用jquery的is(':hidden') )?

我可以控制兩個域-我可以設置CORS,屬性等等。 我嘗試的一切仍然給我類似的東西:

Uncaught SecurityError: Blocked a frame with origin "http://s-college.mydomain.com" from accessing a frame with origin "http://qaf.ng.mydomain.com". Protocols, domains, and ports must match.

如果有幫助,則基本域實際上是相同的,只是子域是不同的。

如果它們都在同一高級域中(例如foo.example.combar.example.com ),則可以在JavaScript中設置document.domain

document.domain = 'example.com';

這將允許跨框架通信。

CORS僅適用於(主要是AJAX)請求,因此此處不適用。

以防萬一其他人發現在相同的較高級別域中沒有它們的問題:如果它們在不同的域中,則需要使用window.postMessage進行跨框架通信。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM