简体   繁体   English

IE9 SCRIPT5访问被拒绝

[英]IE9 SCRIPT5 Access denied

I want to send post request with files and some text fields via iframe transport. 我想通过iframe传输发送带有文件和一些文本字段的发布请求。

(jquery-file-uload + jquery.iframe-transport) (jquery-file-uload + jquery.iframe-transport)

The url of main page http: //192.168.1.36:3001/index.html . 主页的http: //192.168.1.36:3001/index.html The request url is http: //192.168.1.36:3001/api/upload . 请求网址是http: //192.168.1.36:3001/api/upload

I've already read: 1 2 3 4 5 6 7 我已经读过: 1 2 3 4 5 6 7

etc questions. 等问题。

Additional information: 附加信息:

browser: ie 9.0.8112.16421

headers of /index.html: 

Cache-Control:no-cache
Cache-Control:public, must-revalidate, proxy-revalidate
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Thu, 25 Sep 2014 19:34:41 GMT
Expires:Thu, 25 Sep 2014 19:34:40 GMT
Last-Modified:Thu, 25 Sep 2014 19:17:41 GMT
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"
Pragma:public
Server:nginx/1.6.2
Transfer-Encoding:chunked
Vary:Accept-Encoding

domain in iframe is 192.168.1.36, domain in main page is same (192.168.1.36)

But "SCRIPT5 Access denied" in "form[0].submit()" . 但是"SCRIPT5 Access denied" in "form[0].submit()" I replaced "form.submit()" to "form[0].submit()" . 我将"form.submit()" to "form[0].submit()"替换"form.submit()" to "form[0].submit()"

Also I tried to add to the form a special submit button and attempted to trigger('click'). 我也尝试在表单中添加一个特殊的提交按钮,并尝试触发(“单击”)。 Doesn't work. 不起作用

Is it possible?? 可能吗??

Thanks 谢谢

@John, @约翰,

When you wrote: 当你写:

Also I tried to add to the form a special submit button and attempted to trigger('click'). 我也尝试在表单中添加一个特殊的提交按钮,并尝试触发(“单击”)。 Doesn't work. 不起作用

does that mean that you were trying to trigger the file browse using something other than the <input type="file"> element? 这是否意味着您试图使用<input type="file">元素以外的其他内容触发文件浏览? Eg Trying to style the browse button by hiding the file input element? 例如,尝试通过隐藏文件输入元素来设置浏览按钮的样式?

If so, the SCRIPT5 error is because IE9 thinks it's being secure trying to prevent an upload not initiated by the user. 如果是这样,则SCRIPT5错误是因为IE9认为尝试阻止用户未启动的上载是安全的。

Solution: If you style the file input element to be visibility: hidden; 解决方案:如果将文件输入元素的样式设置为visibility: hidden; instead of display: none , and you use a label to initiate the action, it will work. 而不是display: none ,并且您使用标签来启动操作,它将起作用。 You can style the label as you want and it will do almost everything you want it to (I couldn't get it to work with keyboard focus & Enter key). 您可以根据需要设置标签样式,它几乎可以完成您想要的所有操作(我无法通过键盘焦点和Enter键使它起作用)。

eg The following worked for me: 例如以下对我有用:

<label class="my-label-button-style">
    <input type="file" class="my-ie9-hidden-file-input"/>
    Click me
</label>

and CSS: 和CSS:

.my-ie9-hidden-file-input {
    visibility: hidden;
    position: absolute;
    width: 1px;
    height: 1px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM