SCRIPT5:文件上传时IE9拒绝访问 [英] SCRIPT5: Access is denied in IE9 on file upload

查看:697
本文介绍了SCRIPT5:文件上传时IE9拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在ie 9上使用 document.forms [0] .submit()发布带有文件上传框的表单时,我们得到一个错误: SCRIPT5:访问被拒绝



如果再单击几次,就可以正常工作了。



作为一个解决方法,我已经发现了错误,并尝试了几次似乎工作得很好。



有没有解释呢?该代码已经在所有其他流行的浏览器工作了多年。



如果浏览器设置为IE9兼容模式,代码也可以在IE9中正常工作,但这不是我们有一个普遍的控制权。

我已经看到引用 XMLHTTP 是一个问题,我们执行一个 XMLHTTP 调用,但它发生在点击按钮提交之前。

解决方案

事实证明,安全问题是由于我们在弹出窗口中运行文件提交代码。弹出窗口打开window.open有一个空字符串作为请求的页面。然后,我们发布了一个表单到这个窗口。



问题在于,弹出窗口的URL默认为about:blank。很明显,关于:空白被认为是不安全的,所以当试图将文件发回原始域时,SCRIPT5:访问被拒绝出现错误。

解决方法是使用一个小的存根类型的HTML页面打开,然后执行该帖子。一旦选择了一个文件,FILE文件没有看到错误,并且文件按要求填写。


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.

解决方案

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.

这篇关于SCRIPT5:文件上传时IE9拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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