简体   繁体   English

了解 Iframe 中的跨域问题

[英]Understanding Cross-Domain issue in Iframes

This question might seem silly but I need to understand this for clarity.这个问题可能看起来很愚蠢,但为了清楚起见,我需要理解这一点。

According to my understanding, cross-domain problem is when the domain of the webpage which contains the IFRAME is different from the domain of the web-page opened in IFRAME.根据我的理解,跨域问题是当包含 IFRAME 的网页的域与在 IFRAME 中打开的网页的域不同。

Going by that logic, nothing should open in IFRAME ever.按照这个逻辑,任何东西都不应该在 IFRAME 中打开。

When I embed a web-page "bottom:10700" in the IFRAME of my web-page "top:9700", it gives error.I am not able to see the contents in IFRAME.当我在我的网页“top:9700”的 IFRAME 中嵌入一个网页“bottom:10700”时,它给出了错误。我看不到 IFRAME 中的内容。 Error is Access denied in accessing property 'constructor'错误是Access denied in accessing property 'constructor'

I am getting the error while accessing the contructor (_1.contructor)访问构造函数 (_1.contructor) 时出现错误

isc.A.Function=function isc_isA_Function(_1){
  if(_1==null) return false;
  if(isc.Browser.isIE&&typeof _1==this.$a7) return true;
  var _2=_1.constructor;
  if(_2&&_2.$k!=null){
    if(_2.$k!=1)return false;
    if(_2===Function)return true
  }

This script is run when home page of bottom is opened in an iframe contained in top.当在包含在顶部的 iframe 中打开底部的主页时,将运行此脚本。

Is there any way, I can make this work.有什么办法,我可以做这个工作。 I mean can I set both the domains to be same.我的意思是我可以将两个域设置为相同。 I don't have access to remote site's script.我无权访问远程站点的脚本。

Is resizing the frame after redering it once a cross-domain scenario.在跨域场景重新绘制后调整框架的大小。 If not, then certainly remote site is trying to access the IFRAME element..How can I debug this??如果没有,那么肯定是远程站点正在尝试访问 IFRAME 元素..我该如何调试?

Cross-domain issues are about the communication between iframes.跨域问题是关于 iframe 之间的通信。 You can always embed any iframe but, if domains differ, iframes cannot interact with each other eg execute JS, modify DOM etc.您始终可以嵌入任何 iframe,但是,如果域不同,iframe 无法相互交互,例如执行 JS、修改 DOM 等。

HTML5 provides a sandbox property that re-enables particular features of the cross-domain iframe interaction. HTML5 提供了一个sandbox属性,可以重新启用跨域 iframe 交互的特定功能。 Be careful, it can be dangerous.小心,这可能很危险。

It is normal behavior for a page xyz.com to load in an iframe hosted on abc.com.在 abc.com 上托管的 iframe 中加载页面 xyz.com 是正常行为。 However, you cannot change anything or access its content via code from parent abc.com.但是,您不能通过父 abc.com 的代码更改任何内容或访问其内容。

Hope this helped.希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM