SCRIPT5: Access is denied in IE9 on file upload

爱⌒轻易说出口 提交于 2020-01-21 11:04:16

问题


When posting a form with a file upload box using document.forms[0].submit() on ie 9 we get an error that says: SCRIPT5: Access is denied

If I click a few more times it works fine.

As a work around I've caught the error and try a few more times which seems to work just fine.

Is there any explanation on this? The code has worked for years on all the other popular browsers.

The code also works fine in IE9 if the browser is set to IE9 compatibility mode, but that is not something we have general control over.

I've seen references to XMLHTTP being an issue and we do execute a XMLHTTP call but it happens before the button to submit is clicked.


回答1:


It turns out that the security issue is due to the fact that we were running the file submit code in a pop up window. The pop up window was opened with window.open which had an empty string as the requested page. We then posted a form to that window.

The problem is that the URL of the pop up window is defaults to about:blank when not specified. Apparently about:blank is considered insecure so when the attempt to POST the file back to the originating domain is made the SCRIPT5: Access is denied error arises.

The solution is to use a small stub type of html page to open and then perform the post. Once a file is chosen the FILE post does not see the error and the file makes it up as desired.



来源:https://stackoverflow.com/questions/6138859/script5-access-is-denied-in-ie9-on-file-upload

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