dev1223
dev1223

Reputation: 1159

File input click event not fired after page load

After some simplifications, code looks like this

$(function(){
  var x = $("<input type='file'>");
  $(document.body).append(x);
  x.trigger("click");
});

After page loads, nothing happens, but when I open console and call trigger("click") on it, it opens dialog as it should. What's the reason of first time event ignoring?

Use chrome Version 52.0.2743.116 (64-bit)

Upvotes: 0

Views: 196

Answers (1)

Jota Bullon
Jota Bullon

Reputation: 13

Hi this trick only works on IExplorer. Input file can't be automatically triggered in (onload, pageload, document.ready...) due to security purpose

Upvotes: 0

Related Questions