views:

2621

answers:

3

function CaptureKeys (e,btn) {

var c //= document.layers ? evt.which: document.all ? event.keyCode : evt.keyCode

if(window.event) // IE { c = e.keyCode; } else if(e.which) // Netscape/Firefox/Opera { c = e.which; } if (c == 13) //return /enter key { if (btn=="go") { if (document.getElementById("ctl00_ContentPlaceHolder1_btnGo")!=null) { document.getElementById("ctl00_ContentPlaceHolder1_btnGo").focus(); return true; } } else { if (document.getElementById('ctl00_ContentPlaceHolder1_ImgFilter') != null) { //__doPostBack('ctl00_ContentPlaceHolder1_ImgFilter',''); document.getElementById('ctl00_ContentPlaceHolder1_ImgFilter').focus(); return true; } } return false; } } This code is working on IE7 but not working on mozilla firefox. Please help me to raise button event when press enter key.

A: 

You can simply add the UseSubmitBehavior="true" attribute value to your button that should be fired on enter key.

Sachin Gaur
A: 

you can also try theButton.click();

A: 

I dont know if anyone is checking this thread anymore, but for future reference:

I had the same problem in FF and I got the answer here:

http://www.webdeveloper.com/forum/showthread.php?t=108382

good luck!

related questions