在 IE8 上访问被拒绝错误 [英] getting access is denied error on IE8

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

问题描述

我有一个 HTML 表单 (upload.htm),其中包含一个 HTML 文件上传控件.

I have a HTML form (upload.htm) with a HTML file upload control inside of it.

<form id="frmupload" name="upload" enctype="multipart/form-data" action="uploadhandler.ashx" method="post">
    <input id="uploader" name="uploadctrl" type="file"/>
</form>

在上面的页面中还有一个 JavaScript 方法是这样的:

There is also one JavaScript method in the above page which goes like:

function performUpload(){
    document.getElementById('frmupload').submit();
}

我在 iframe 中的页面 (uploadpage.htm) 中调用它:

I call this inside of a page (uploadpage.htm) from within an iframe:

<iframe id="docframe" src="upload.htm" style="display:none"></iframe>

我尝试从 uploadpage.htm 页面执行下面显示的语句:

I try to execute the statement shown below from the uploadpage.htm page:

var i = document.getElementById('docframe');
i.contentWindow.performUpload();

我收到一条错误消息,说访问被拒绝,我的调试器在我展示的第一个 JavaScript 函数处停止.这两个文件位于 Web 项目中的同一位置.他们也有相同的域名.为什么我会收到这个错误?

I get an error saying Access is denied, and my debugger halts at the first JavaScript function I've shown. Both the files are in the same location in the web project. They have the same domain name too. Why do I get this error then?

当然,之前我可以发布页面:当我没有为 HTML 上传控件设置 name 属性时.但是在 HTML 标记中设置 name 属性后,我收到了这个奇怪的错误.为什么我第一次没有得到这个?

Of course, earlier, I could post the page: when I did not set the name attribute for the HTML upload control. But after I set the name attribute in HTML markup, I get this weird error. Why didn't I get this the first time?

看看@这个帖子--> 拒绝访问"当脚本尝试在 IE8 中访问 iframe 时,但没有帮助.

Had a look @ this post --> "Access is denied" when script tries to access iframe in IE8, but it didn't help.

推荐答案

出于安全原因,IE 不允许从 javascript 操作 type="file" 输入元素.设置文件名或调用单击事件以显示浏览器对话框将导致表单提交时出现访问被拒绝"错误 - Internet Explorer 很聪明地记住调用了哪些方法.

IE doesn't allow manipulation of the type="file" input element from javascript due to security reasons. Setting the filename or invoking a click event to show the browser dialog will result in an "Access is denied" error on the form submit - Internet Explorer is clever about remembering what methods have been invoked.

类似问题:http://www.webdeveloper.com/forum/showthread.php?t=181272

这篇关于在 IE8 上访问被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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