简体   繁体   中英

Upload via Iframe, IE8/9 access is denied (cross domain)

I'm using an iframe for upload file from a modal pop-up. File is send to the server and respond fine, but when i try to access to the contentDocument of the iframe response i got access is denied. So i try to set the src :

iframe[0].src = javascript:'<script>window.onload=function({document.write(\\'<script>document.domain=\\\"" + document.domain + "\\\";<\\\\/script>\\');document.close();};<\/script>'

But this does'nt change anything...

Thanks for your help.

UPDATE :

They have both http... I try another scr. But when i view the response iframe with console.log, i see :

<iframe name="iframeTransport1411732701469" src="javascript:(function(){document.open();document.domain="localhost";var ed = window.parent.CodeMirror_boilerplate;document.write(ed);document.close();})()">

So javascript isn't interpreted... What i'm doing wrong ?

Try to check the protocol of both: iframe:

document.getElementById('iframeId').contentWindow.document.location.protocol

and parent page:

document.location.protocol

If they are different (http vs https) them it is considered cross reference domain and you cannot change them.

Other thing is an absolute URL - points to another web site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM