Can I double-click with one click the form input button [type = "file"]?

I have a form inputfor sending a file, and I created it because I did not like the native style. Now I have one button, which, when clicked, opens a dialog box for selecting a file. It works great with one click on Firefox and Chrome, but it does not work in IE. The button should double-click to open a dialog in IE.

I tried to double click with one click using jQuery:

$("input").click(function() { 
    $(this).dblclick(); 
});

However, it does not work. Is there any other double click approach for IE?

Here's the demo: http://jsfiddle.net/HAaFb/

+5
source share
8 answers

dblclick, , IE... ? , , ( ?)

$("#formId").find("input[type='file']").trigger('click');

:

$("input").click(function() { 
    $('input[type="file"]').click(); 
});

$('input[type="file"]').hide().parent().append($('<span />').attr('class', 'filebutton').text('Upload'));
$(".filebutton").click(function() { 
    $('input[type="file"]').click(); 
});

CSS

form {
    color:#666;
}
.filebutton {
    content:'upload';
    font:small-caps 15px Georgia;
    letter-spacing:1px;
    border-radius:10px;
    border:1px solid #eee;
    width:100px;
    padding:10px;
    margin:20px;
    text-align:center;
    position:absolute;
    left:0;
    top:0;
    z-index:1;
    background-color:#f8f8f8;
}

.filebutton:hover {
    background-color:#f3f3f3!important;
    color:#c00;
     cursor : pointer;
}

...

+2

, jQuery ( "" ), "" " ". , IE 8/9/10, .

http://blueimp.imtqy.com/jQuery-File-Upload/

CSS :

.fileinput-button input {
...
right: 0px;
...
transform: translate(300px, 0) scale(4);
}
+3

- :

var count=0;
$("input").click(function(e) { 
    count++;
    if(count==2){
         count=0;
    }else{
        e.preventDefault();
    }
});

DEMO: http://jsfiddle.net/HAaFb/1/

http://jsbin.com/ukotit/17/edit

+2

native/ActiveX IE - .

?

+1

, , , , - , :

$("#uploadInput").bind('mousedown', function (event) {
    $(this).trigger('click')
});

IE10, IE11.

+1
$("input").click(function() { 
    $(this).trigger('dbclick');
});
0

, , - :

$('input').on('click', function() {
  $(this).trigger('dblclick');
});

, , -.

0

CSS... IE, , .

, : IE9, . JSFiddle IE7/8, .

0

All Articles