I want to implement a click event with type as file as soon as I enter the page, and then get the selected image information. My code is
var _file = document.createElement("input");
_file.setAttribute("type", "file");
_file.setAttribute("style", "display:none;");
_file.setAttribute("height", "0px");
_file.setAttribute("width", "0px");
_file.setAttribute("id", "_file-id");
document.body.appendChild(_file);
document.getElementById("_file-id").click();
document.getElementById("_file-id").onchange = function(e) {
alert(1)
}
write this, no matter how you look at it, but it does not trigger the click event of file directly on Google browser, but it triggers the click event on ie browser, but when I select the picture, I do not execute the onchange event. I ask God to tell me that it is written correctly and is compatible with these two browsers.
Thank you very much!