开发者

jquery upload read innerHTML from external domain on same webserver

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)

I use

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

but I get this error

Unsafe JavaScript attempt to access frame with URL

Domains, protocols and port开发者_JAVA百科s must match.

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

it returns this

ok|image.gif|458=458

Thanks


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

Quoting:

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.

Take a look at JSONP to work around it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜