Guest Annette Posted October 17, 2006 Share Posted October 17, 2006 I am trying to force a location.href on receipt of an enter within a text box. It works fine in IE but in Netscape and Firefox it appears to be reloading the current page and not going to the new URL. I am out of ideas to try. Any help would greatly appreciated!!!!See below for code:function checkEnterFindAnything(event){ var code = 0; if(window.event) // IE { code = event.keyCode; if (code==13) { dosavesearch(); } } else // Netscape/Firefox/Opera { code = event.which; if (code==13) { dosavesearch(); } }}function dosavesearch(){ errorstring = "" temp = trim(document.SFM.txtSearch.value); if(temp == "") { errorstring = errorstring + "You must enter what you want to find!\r"; } if(errorstring == "") { location.href = "<%=Application.Value("Shop4MilesURL")%>Search.asp?SS=" + temp; } else { window.alert(errorstring) }}</script> <td width="128" align="left" valign="middle"><input name="txtSearch" onKeyPress='checkEnterFindAnything(event)' type="text" size="16"></td> <td width="43" align="left"><a href='java script:dosavesearch()'><img name="go" id="go" src="../elements/buttons/go.gif" width="30" height="18" border="0" alt=""></a></td> Link to comment Share on other sites More sharing options...
jesh Posted October 17, 2006 Share Posted October 17, 2006 Here's the CheckForEnter script I use. I don't think it works in Safari on the Mac yet - I've been too busy to try to get it to work. But it works for me in IE and Firefox (PC and Mac). function CheckForEnter(e){ var charcode; if(!e) { e = event; } if(e.which) { charcode = e.which; } else { charcode = e.keyCode; } if(charcode == 13) { // ENTER was pressed. }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now