jquery upload read innerHTML from external domain on same webserver

扶醉桌前 提交于 2020-01-07 05:36:08

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/6696612/jquery-upload-read-innerhtml-from-external-domain-on-same-webserver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!