I need to simulate a click on an anchor link through javascript. But it only works in IE 7, not in FF 2.
Basically I need to capture an Enter-click on a textbox and call the right button to execute afterwards.
I've added the following to the onkeydown attribute on the textfield:
if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('searchButton').click();return false;}} else {return true}; "
The "searchButton" is an html anchor (
) and in IE7 the "click" is performed without problems. In firefox it says that ....click is not a function.
So I'm a bit confused here. Anybody know what is the problem?