Plupload& jQuery不能在IE中工作

时间:2012-11-13 16:41:48

标签: jquery plupload

Plupload正在所有浏览器中运行IE吧。在IE中按#photo-upload链接后,文件浏览器无法打开。 uploader的实例肯定是使用Dev工具正确创建的。

非常感谢任何解决方案!

这是我们用来创建上传器的脚本:

        var uploader = new plupload.Uploader({
            runtimes : 'gears,html5,flash,silverlight,html4',
            browse_button : 'photo-upload',
            container : 'img-container',
            url : 'productPhoto.php?id=<?=$_GET["id"];?>',
            max_file_size : '5mb',
            flash_swf_url : '/dev/plupload/js/plupload.flash.swf',
            silverlight_xap_url : '/dev/plupload/js/plupload.silverlight.xap',
            unique_names : true,
            filters : [{title : "Image files", extensions : "jpg,gif,png"}],
            multipart_params: {type:1},

            // Post init events, bound after the internal events
            init : {
                UploadProgress: function(up, file) {
                    // Called while a file is being uploaded
                    $("#bar").css("width",file.percent+"%");
                },
                FilesAdded: function(up, files) {
                    $(".progress").slideDown();
                    uploader.start();
                    up.refresh(); // Reposition Flash/Silverlight
                },
                UploadComplete: function(up, file, info) {
                    // Called when a file has finished uploading
                    setTimeout(function(){
                        $(".progress").slideUp();
                        $("#bar").css("width","0");
                        document.location.reload();
                    },2000);
                },
                Error: function(up, args) {
                    // Called when a error has occured
                    alert(args);
                    up.refresh(); // Reposition Flash/Silverlight
                }
            }
        });
        uploader.init();

3 个答案:

答案 0 :(得分:3)

链接位于下拉列表中的问题 - 在开始时隐藏。链接必须可见。

答案 1 :(得分:1)

我可以建议避免将上传控件放在隐藏的容器中。

<div class="container" style="display:none">
    <a id="pickfiles" href="#">[Select files]</a>
    <a id="uploadfiles" href="#">[Upload files]</a>
</div>

在上面的示例中,container div有一个描述display:none属性的样式元素。这就是它在IE中无法工作的原因。

只需将其更改为display:block或删除样式元素即可。

答案 2 :(得分:0)

我在IE 8中的页面加载时隐藏了plupload div时遇到了同样的问题。我选择绝对将div放在屏幕上,然后在需要时传入新的顶部/左侧坐标:< / p>

    #plupload {
        display: block;
        position:absolute;
        top:-999px;
        left:-999px;
        background:#fff;
        border:1px solid #c8c8c8;
        padding:10px;
        z-index: 951;
    }

    $('#some-button-to-open-plupload-widget').button().click(function() {
         var css = {"top":"175px", "left":"175px"};
         $("#plupload").css(css);
    });

    $('#some-button-to-close-plupload-widget').button().click(function() {
         var css = {"top":"-999px", "left":"-999px"};
         $("#plupload").css(css);
    });

    <div id="plupload">
       <a href="" class="ui-icon ui-icon-close" id="close"></a>
       <div id="uploader" style="display:block">
           <p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
       </div>    
    </div>