了解Iframes中的跨域问题 [英] Understanding Cross-Domain issue in Iframes

查看:102
本文介绍了了解Iframes中的跨域问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



根据我的理解,跨网域问题是当网页所在的网域包含IFRAME与在IFRAME中打开的网页的域不同。



按照该逻辑,IFRAME中不应该打开任何内容。



当我在我的网页top:9700的IFRAME中嵌入网页bottom:10700时,它会显示错误信息。我无法看到IFRAME中的内容。错误是在访问属性'constructor'时拒绝访问



访问构造函数时出现错误(_1。构造函数)

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

这个脚本当底部的主页在包含在顶部的iframe中打开时运行。

有没有什么办法,我可以做这个工作。我的意思是我可以设置两个域是相同的。我没有权限访问远程站点的脚本。



调整框架的大小后,重新调整一次跨域方案。如果没有,那么肯定远程站点正在尝试访问IFRAME元素。我怎样才能调试呢?

解决方案

域问题是关于iframe之间的通信问题。您始终可以嵌入任何iframe,但如果域名不同,iframe就无法互相交互,例如执行JS,修改DOM等。

HTML5提供 sandbox 属性,以重新启用跨域iframe交互的特定功能。小心,它可能是危险的。


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.

Going by that logic, nothing should open in IFRAME ever.

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. Error is Access denied in accessing property 'constructor'

I am getting the error while accessing the 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.

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??

解决方案

Cross-domain issues are about the communication between iframes. You can always embed any iframe but, if domains differ, iframes cannot interact with each other e.g. execute JS, modify DOM etc.

HTML5 provides a sandbox property that re-enables particular features of the cross-domain iframe interaction. Be careful, it can be dangerous.

这篇关于了解Iframes中的跨域问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆