javascript - The file selection pop-up window cannot be called up in the callback function
给我你的怀抱
给我你的怀抱 2017-05-19 10:39:48
0
2
635

HTML

<input id="videoInput" type="file" style="display: none" />
<button type="submit" id="videoUploadInput">上传文件</button>

JS

$('#videoUploadInput').click(function (e) {
  e.preventDefault()
  setTimeout(function() {
     document.getElementById('videoInput').click()
  }, 2000)
})

The initial positioning reason is that the click event is triggered by the callback function. At this time, event.isTrusted is false (this attribute is currently only supported in IE and Firefox), rather than being actively triggered by the user, that is, this event is not Trusted by the browser.

给我你的怀抱
给我你的怀抱

reply all(2)
给我你的怀抱

http://stackoverflow.com/ques...

http://stackoverflow.com/ques...

仅有的幸福

1. Change the delayed 2000 to 1000

Link description

2. Delayed processing functions are executed immediately

setTimeout((function(){})(),2000)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template