Is there anyway to make the input type file dialog box pop up when the onmouseover event is triggred? Or any other event besides onclick? (I would like the dialog box to appear onshake, and I’m using a jQuery plugin for the shake event for mobile devices)
There’s a hack where you can onclick on an item, and it would then click on the input type file element (which would be invisible) using JavaScript/jQuery, but it didn’t work when I changed the item to onmouseover or another event.
Edit: My code looks a bit like this, except that I’m using the onshake event (with a jQuery plugin) instead of onmouseover. Some problem though:
<button onmouseover="javascript:opendialogbox('imageuploadform1');">nope!</button>
<script>
function opendialogbox(inputid){
document.getElementById(inputid).click();
}
</script>
<input type="file" id="imageuploadform1" name="picture" />
you can’t:
in this demo works on click : http://jsbin.com/eqenoz/1/edit
now try here with any other event : http://jsbin.com/eqenoz/2/edit
The action that opens a popup MUST be performed by the user itself and has to be a DIRECT-USER-CLICK event.
So mousemove, mouseenter, mouseleave, shakeme, pushme, smileme, … will not work and will throw a browser security warining.
The only thing you can do is ask your user to kindly confirm the warning exception.