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

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

问题描述

这个问题可能看起来很愚蠢,但为了清楚起见,我需要理解这一点.

This question might seem silly but I need to understand this for clarity.

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

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 中打开.

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

当我在网页top:9700"的 IFRAME 中嵌入网页bottom:10700"时,出现错误.我无法在 IFRAME 中看到内容.错误是 Access denied in accessing property 'constructor'

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'

我在访问构造函数 (_1.contructor) 时遇到错误

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
  }

在包含在顶部的 iframe 中打开底部的主页时运行此脚本.

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.

在跨域场景重新绘制后调整框架的大小.如果没有,那么肯定是远程站点正在尝试访问 IFRAME 元素.我该如何调试?

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 之间的通信.您始终可以嵌入任何 iframe,但是,如果域不同,iframe 无法相互交互,例如执行JS,修改DOM等

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 提供了一个 沙盒 属性 重新启用跨域 iframe 交互的特定功能.小心,这可能很危险.

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

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

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