简体   繁体   English

脚本5:访问被拒绝IE09和IE10

[英]SCRIPT5: Access is denied IE09 and IE10

I'm using rails 3.2.11. 我正在使用rails 3.2.11。 I have implemented file upload concept. 我已经实现了文件上传概念。 It is working fine with Firefox and chrome browser. 它适用于Firefox和Chrome浏览器。

Form 形成

<iframe id="upload_target" name="upload_target" style="display:none;"></iframe>
<%= form_tag(url_for(:action => 'add_image'), 
                    :target => 'upload_target',
                    :id => 'add_image_form',
                    :enctype => 'multipart/form-data', :multipart=>true) do %>
    <%= text_field 'image_asset', 'name', :size => [60,40].min, :maxlength => "60", :id => "focus", :style=>"display:none", :value=>"site_logo" %>
    <%= text_field 'image_asset', 'image_type', :value=>"Icon",:style=>"display:none"%>
    <input type="file" id="file" name="image_form_file" size="36" style="display:none;" /> 
    <a href="#" class="button" onclick="$('#file').click();">Upload a new logo image</a>
    <a href="#" class="button green" onclick=" $('#add_image_form').submit();">Save</a>
<% end %>

JQuery JQuery的

    $('#file').live("change",function() {
       $('#add_image_form').submit();
       setTimeout(function(){
        $.ajax({
                type: "GET",
                beforeSend: function(xhr){ xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
                dataType: "html",
                url: "/get_image",
                data: "record_id=<%= @page.id%>&format=html",

                success: function(data){
                    $('#site_logo').html(data);
                    var new_image = $('#site_logo').find("img").attr('src');
                },
                error: function(){
                }
            });
    }, 6000)    

I have an issue only with in IE 9, IE 10 browser. 我只在IE 9,IE 10浏览器中遇到问题。 The Java script console throws "SCRIPT5: Access is denied." Java脚本控制台抛出“SCRIPT5:拒绝访问”。

I have tried with allow the permission for the folder location but not useful. 我试过允许文件夹位置的权限但没有用。 C:\\Users[USERNAME]\\AppData\\Local\\Microsoft\\Internet Explorer\\DOMStor C:\\Users[USERNAME]\\AppData\\Local\\Packages\\windows_ie_ac_001\\AC\\Microsoft\\Intern‌​et Explorer\\DOMStore C:\\ Users [USERNAME] \\ AppData \\ Local \\ Microsoft \\ Internet Explorer \\ DOMStor C:\\ Users [USERNAME] \\ AppData \\ Local \\ Packages \\ windows_ie_ac_001 \\ AC \\ Microsoft \\ Intern et Explorer \\ DOMStore

Any Suggestion 任何建议

Thanks 谢谢

Try to wrap your button anchor in label tags: 尝试将您的按钮锚包装在标签标签中:

<input type="file" id="file" name="image_form_file" size="36" style="display:none;" /> 
<label for="file" class="button">Upload a new logo image</label>

Clicking the label will trigger the file input without invalidating the form for internet explorer. 单击标签将触发文件输入,而不会使Internet Explorer的表单无效。

(Tested in IE9 & IE10) (在IE9和IE10中测试过)

Using an iframe for file uploads is impossible for the javascript code to determine the HTTP status code of the servers response in IE10. 使用iframe进行文件上传是不可能的,因为javascript代码无法确定IE10中服务器响应的HTTP状态代码。

https://cmlenz.github.io/jquery-iframe-transport/#section-13 https://cmlenz.github.io/jquery-iframe-transport/#section-13

You have to return a success response and evaluate the json data to decide if it was an success or not response. 您必须返回成功响应并评估json数据以确定它是否成功响应。

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

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