Quantcast
Channel: The New Dawn » programming
Viewing all articles
Browse latest Browse all 8

Simulating Button Click() Event in Firefox

$
0
0

We cannot directly simulate click event in Firefox. Add the following code to register mouseclick event for the button.

HTMLElement.prototype.click = function() {
var evt = this.ownerDocument.createEvent(‘MouseEvents’);
evt.initMouseEvent(‘click’, true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}

Then, you may call the event in Firefox as if you do in IE.

For client-side button: document.getElementById(’btnUpdate’).click();
For server-side button: document.getElementById(’<%= this.btnUpdate.ClientID %>‘).click();


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles



Latest Images