jQuery上传从同一Web服务器上的外部域读取innerHTML [英] jquery upload read innerHTML from external domain on same webserver

查看:84
本文介绍了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 可以解决此问题.

这篇关于jQuery上传从同一Web服务器上的外部域读取innerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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