" SCRIPT5访问被拒绝"从的onchange射击IE9时出现错误。点击() [英] "SCRIPT5 Access is denied" error on IE9 when firing .click() from onchange

查看:683
本文介绍了" SCRIPT5访问被拒绝"从的onchange射击IE9时出现错误。点击()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望减少的花费用户上载在我们的网站文件的步数;所以我们使用jQuery打开和使用下面的标记(简体)回​​发的文件:

We want to reduce the number of steps it takes for a user to upload a file on our website; so we're using jQuery to open and postback files using the below markup (simplified):

<a onclick="$('#uplRegistrationImage').click();">
    Change profile picture
</a>

<!-- Hidden to keep the UI clean -->
<asp:FileUpload ID="uplRegistrationImage" 
                runat="server" 
                ClientIDMode="static"
                Style="display:none"
                onchange="$('#btnSubmitImage').click();"    />

<asp:Button runat="server" 
            ID="btnSubmitImage" 
            ClientIDMode="static" 
            Style="display:none" 
            OnClick="btnSubmitImage_OnClick" 
            UseSubmitBehavior="False" />

这在Firefox和Chrome精绝;打开文件对话框中单击链接时,当选择文件射击回发。

This works absolutely fine in Firefox and Chrome; opening the file dialog when the link is clicked and firing the postback when a file is selected.

然而在IE9后文件上载已加载并且用户已经选择了一个文件; insteaed的的OnChange工作我得到一个SCRIPT5访问被拒绝的错误。我试过设置任意超时设置的时间间隔检查文件是否被赋予无济于事。

However in IE9 after the file upload has loaded and a user has selected a file; insteaed of the OnChange working I get a "SCRIPT5 Access is denied" error. I've tried setting an arbitrary timeout, setting intervals to check if a file is given to no avail.

有一些与此的其他问题;但是,没有出现一个像样的答案(一说设置文件对话框是透明和悬停一个按钮后面!)

There are a number of other questions relating to this; however none appear to have a decent answer (One said set the file dialog to be transparent and hover behind a button!)

有没有其他人解决了这个?抑或是绝对必要的,我为IE用户提供一个按钮?

Has anyone else resolved this? Or is it absolutely necessary that I provide a button for IE users?

推荐答案

有关安全方面的原因,你正在尝试做的是不可能的。这似乎是IE9不会让你提交表单这样,除非它是在触发它的文件上传控件的实际点击鼠标。

For security reasons, what you are trying to do is not possible. It seems to be the IE9 will not let you submit a form in this way unless it was an actual mouse click on the File Upload control that triggers it.

有关参数的缘故,我能够使用code做了变更处理程序提交,但它的工作的当我点击了浏览按钮自己。我甚至成立了的$(document)的投票。就绪通过指示变更处理程序中设置一个变量法提交一个应该触发 - 这也不能工作。

For arguments sake, I was able to use your code to do the submit in the change handler, but it worked only when I clicked the Browse button myself. I even set up polling in the $(document).ready method for a variable set by the change handler that indicates a submission should be triggered - this didn't work either.

对这个问题的解决办法似乎是:

The solutions to this problem appear to be:


  1. 的样式,因为它位于一个按钮后面这样一种方式控制。你在你的问题中提到这一点,但这里罗姆人提供的答案<一个href=\"http://stackoverflow.com/questions/210643/in-javascript-can-i-make-a-click-event-fire-programmatically-for-a-file-input\">In JavaScript的我可以做一个&QUOT;按一下[事件火编程为一个文件输入元素?确实能使工作(我试着在IE9,Chrome的V23和V15 FF)。

  2. 使用基于Flash的方法(如Gmail做到这一点)。我尝试了 Uploadify 演示,它似乎很好地工作。

  1. Styling the control in such a way that it sits behind a button. You mentioned this in your question, but the answer provided by Romas here In JavaScript can I make a "click" event fire programmatically for a file input element? does in fact work (I tried in IE9, Chrome v23 and FF v15).
  2. Using a Flash-based approach (GMail does this). I tried out the Uploadify demo and it seems to work quite nicely.

的样式文件上传:

<一个href=\"http://www.quirksmode.org/dom/inputfile.html\">http://www.quirksmode.org/dom/inputfile.html

<一个href=\"http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom\">http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom

参考文献:

<一个href=\"http://stackoverflow.com/questions/1829774/jquery-simulating-a-click-on-a-input-type-file-doesnt-work-in-firefox?lq=1\">jQuery :模拟在℃的点击;输入类型=&QUOT;文件&QUOT; /&GT;在Firefox不起作用?

IE9文件输入使用Javascript 触发

<一个href=\"http://stackoverflow.com/questions/3935001/getting-access-is-denied-error-on-ie8/6376654\">getting访问被拒绝在IE8 误差

这篇关于&QUOT; SCRIPT5访问被拒绝&QUOT;从的onchange射击IE9时出现错误。点击()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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