I have a href from which I am giving out a popup, and I want to activate this in my body’s onload. I use document.getElementbyId("myelement").click() which works fine in IE but Firefox doesn’t support it. I know that .click() will not be supported by Firefox , but I don’t have any other way to do it.
Can you please suggest a workaround that works in IE as well as in Firefox?
You can do as Alsciende suggests, or if you need the event object you can use
dispatchEventto trigger an event handler:It’s sometimes useful to use a framework, such as jQuery, to handle these sorts of browser inconsistencies for you. More or less, the same code in jQuery would be: