Trapping the enter key

wxdqz

New Member
I'm trapping the enter key and executing a javascript validation function "CheckValue()" by using the following javascript:

if (self.event.keyCode == 13)
{
if ( CheckValue(1,"<%=strNextPage%>") )
document.frmData.submit();
}

(I'm only concerned about IE!) This works great EXCEPT when an image of a button (within anchor tags with a hyperlink ) has focus and the user presses the enter button. IE then processes the validation function and also opens the window which the anchor tag href attribute points to. The anchor tag is below.
<a href=http://www.webdeveloper.com/forum/archive/index.php/"javaScript:openWindow('../PolicyInfo.asp?EMSessionID=<%=Request("EMSessionID")%>','statusbar=no,toolbar=yes,scrollbars=yes,resizable=yes')"><img name="ViewPolicyInfo" border="0" src=http://www.webdeveloper.com/forum/archive/index.php/"<%=getstring("policyinfo", selectednode1)%>"></a>

How do I detect the user is on the image when the enter button is pressed? Giving it a name and looking to see if it has focus doesn't work, neither does using a submit button to trap the enter key. The submit button seems to only work if a TEXTBOX has focus. Any help will be greatly appreciated. Thanks!
 
Back
Top