jQuery上传从同一Web服务器上的外部域读取innerHTML

问题描述:

我在mysubdomain上有一个php文件,并希望使用该脚本来管理我所有域的上传(所有域都驻留在同一台Web服务器上)

I've one php file on mysubdomain and want to use that script to manage uploads for all my domains (all reside on same webserver)

我用

var resposta = document.getElementById('iframe_uploads').contentWindow.document.body.innerHTML

但我收到此错误

Unsafe JavaScript attempt to access frame with URL

Domains, protocols and ports must match.

我的问题是,有什么方法可以从此iframe中读取inneHTML吗?

My questio is, is there a way I can read the inneHTML from this Iframe?

它返回

ok|image.gif|458=458

谢谢

这是因为相同的原产地政策要求域和协议必须匹配.

That's because of Same Origin Policy which requires that domain and protocol must match.

报价:

在计算中,相同来源策略是重要的安全概念 适用于多种浏览器端编程语言,例如 JavaScript.该策略允许脚本在原始页面上运行 从同一个站点访问彼此的方法和属性 没有具体限制,但阻止访问大多数方法和 跨不同网站上的页面的属性.

In computing, the same origin policy is an important security concept for a number of browser-side programming languages, such as JavaScript. The policy permits scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.

看看 JSONP 可以解决此问题.