Current html / javascript code...
function myfunction() {
alert("hello");
document.getElementById('file').click();
}
<body onload="myfunction();">
<input type="file" id="file" />
</body>
Now alert
is displayed, but file is not clicked on onload
event but if we change the event to onclick
, the alert
is shown as well as file is also clicked.