javascript - Alternative for .click() method in Firefox -


I have href , from which I am giving a popup, and I activate it I want to use document.getElementbyId ("myelement") in my body's onload . Click () which works fine in IE but Firefox does not support it. I know that . Click () will not be supported by Firefox, but I have no other way of doing this.

Can you please suggest an alternative solution that works in IE as well as in FF?
Thanks in advance.

You can do this as a suggestion of alceendi, or if you need an event object then you can You can use dispatchEvent to trigger an event handler:

  Document.body.onload = function {var element = document.getElementById (" Element"); If (element "click") element.click (); Otherwise if (element "Send Event") {var evt = document.createEvent ("MouseEvents"); Evt.initMouseEvent ("click", true, true, window, 0, 0, 0, 0, false, false, false, false, 0, zero); Element.dispatchEvent (evt); }}  

It is sometimes useful to use a framework useful, for example, to control these browser browser discrepancies, more or less, in jQuery The same code would be:

  $ ('# element'). Click ();  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -