Pressing Enter Key from a Textbox (Netscape 4.79) and simulate a button-click

G

GOKU24

I have a regular html textbox and button. When the user presses
"Enter" from the keyboard instead of clicking the "Go" button I would
like the code that would have run by clicking the button work the same
way when they press the Enter key.


I have it working in IE, but I can't find anything useful in Netscape.
I can capture events, but the problem there is that it still submits
the form when the Enter key is pressed. The button I use is not a
submit button. It just calls a JavaScript function when clicked.
Does Netscape have anyway to simulate a button click? This is the IE
code:

<script language="javascript">
function catchKeyPress(code, sender) {
var ret=null;

testForEnterAndEsc();

if(code == '13') {
if(sender.name == 'SearchArg'){
ret=document.getElementById("btnGo");
}

if(ret) {
ret.click();
}
}
}

function testForEnterAndEsc() {
if (event.keyCode == 13){// || event.keyCode == 27) {
event.cancelBubble = true;
event.returnValue = false;
}
}
</script>


Is Netscape capable of anything close to this? How can I get page not
to PostBack when pressing the Enter key from a textbox?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top