While following the answer here: Click() works in IE but not Firefox
I no longer get the "click is not a function message" error message and indeed get the "Clicked" alert message, however the browser does not navigate to the page. I tried it on the latest version of firefox and it navigates, just not happening in Firefox 2.
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);};
document.onclick= function(event) { if (event===undefined) event= window.event; var target=
'target' in event? event.target : event.srcElement; alert("clicked");};
document.getElementById("anId").click();
document.onclick= function(event) { if (event===undefined) event= window.event; var target=
'target' in event? event.target : event.srcElement; alert("clicked");};
Use
document.getElementById("anId").onclick();
it will work on all the browsers.click();
works only on IE.