As such right now file browser is opening when we click on browse button but I want it to open when I click on any text, how can I get that? Please guide.

http://javascript.internet.com/forms/file-open.html

2 answers

2
points

See this article

Answered over 6 years ago by Neil Craig
danwellman 5600
0
points

This could be tricky as the file open text field and button are rendered by the browser as a complete unit (i.e. you don't specify a seperate input and button, just the <input> with the type set to file).

Are you saying that you want to open the choose file dialog when literally any text on the entire page is clicked? Won't that be a little confusing for your visitors?

You could do it by setting a click handler on the body which looks for clicks that originate from any <p> element, when such a click is detected (it will bubble all the up to the <body> element) all you need to do is focus the file input and that should bring up the dialog

Answered over 6 years ago by danwellman