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

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

问题描述

我有一个包含HTML文件上传控件的HTML表单( upload.htm )。

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();
}

我将其称为页面内部( uploadpage.htm )从 iframe 中:

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上传控件。但是在我设置了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.

推荐答案

由于安全原因,从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天全站免登陆