I'm writing some JavaScript code that needs to fire the click
event for a link. In Internet Explorer I can do this
var button = document.getElementById('myButton');
button.click();
But this doesn't work in Firefox, and I assume any other browser. In Firefox, I've done this
var button = document.getElementById('myButton');
window.location = button.href;
I feel like this is not the best way to do this. Is there a better way to trigger a click
event? Preferably something that works regardless of the type of element or the browser.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…