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
which works fine in IE but Firefox does not support it. I know that onload
. Click () . 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
Post a Comment