Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox problem... return false not working?

Status
Not open for further replies.

grande

Programmer
Feb 14, 2005
657
CA
So, here's what's up. I have this function:
Code:
function keyclick(e, entity) {
	var keynum;
	if (window.event) {    // IE
		keynum = e.keyCode; }
	else {                 // Opera, Netscape, Firefox
		keynum = e.which; }
	if (keynum == 13) {
		alert(entity);
		pushData(entity);
		alert("Pushing Data");
		return false;
	}
}
As you can see, it calls the pushData function. When fake-stepping through (via alerts), pushdata gets called, and everything *should* be fine. BUT, when the Enter key is pressed, the page reloads. I thought I had taken care of this with the return false (works in IE), but Firefox still reloads the page.

Help?

-------------------------
Call me barely Impressive Captain.
 
Code:
function keyclick(e, entity) {
    var keynum;
    if (window.event) {    // IE
        keynum = e.keyCode; }
    else {                 // Opera, Netscape, Firefox
        keynum = e.which; }
    if (keynum == 13) {
        alert(entity);
********pushData(entity);********
        alert("Pushing Data");
        return false;
    }
}

Keyclick is called here:
Code:
OnKeyDown="javascript:return keyclick(event, 'AuditTable_lblConstructionSC');"

-------------------------
Call me barely Impressive Captain.
 
try removing the javascript: code prefix - they don't go in on* attributes.
 
Does Fx give they keycode as 13? Does this alert correctly? Can you give some more detail about the element with the onkeydown? Perhaps the whole element? At present you only seem to give away the minimum asked for rather than something marginally richer.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top