javascript - open FileSelect dialog programmatically -


I am trying to open a file select dialog box without contacting the user, but it does not work and I Do not understand why

In this example, I am trying to open it from the window. Ollod function, but it does nothing. The console output shows that the "simulateclick ()" function is executed, but I do not see the dialog box.

When I use the 'Test' button instead, it works fine.

To make a call besides "document.getElementById ('files'). Click ()" There is no effect from the console.

Can anyone explain?

  & lt; Html & gt; & Lt; Body & gt; & Lt; Input type = "file" id = "file" name = "files []" multiple & gt; & Lt; Input type = "button" id = "test" value = "test" & gt; & Lt; Script & gt; Function simulatorclick () {console.log ("first"); Var elem = document.getElementById ('file'); Console.log (ELEM); Elem.click (); Console.log ("after"); }; Window.onload = simulateclick; Document.getElementById ('test'). Onclick = simulateclick; & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -