nikhilh
asked on
Problem with Accesskey in IE
I am trying to make this piece of code to work on IE 5.x but it does not. I was to execute a piece of javascript when accelerator key Alt+P is pressed.
Any suggestions to make it work?
It apparently works very well with Netscape 6.2
<html>
<head>
</head>
<body>
<a accesskey="p" href="javascript:alert('Th is is an alert')">
<img src="bin.jpg" name="left" border="0" alt="Click or 'ALT P' for previous page" WIDTH="30" HEIGHT="26"></a>
</body>
</html>
Nikhil
Any suggestions to make it work?
It apparently works very well with Netscape 6.2
<html>
<head>
</head>
<body>
<a accesskey="p" href="javascript:alert('Th
<img src="bin.jpg" name="left" border="0" alt="Click or 'ALT P' for previous page" WIDTH="30" HEIGHT="26"></a>
</body>
</html>
Nikhil
Seems like a Bug.
This workaround seems to work :
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function pCheck()
{
if (event.keyCode!="80" || !event.altKey)
{
return true;
}
document.getElementById("a a").click( );
}
//-->
</SCRIPT>
</head>
<body onkeydown="pCheck();">
<a id="aa" href="javascript:alert('Th is is an alert')">
<img src="bin.jpg" name="left" border="0" alt="Click or 'ALT P' for previous page" WIDTH="30" HEIGHT="26"></a>
</body>
</html>
This workaround seems to work :
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function pCheck()
{
if (event.keyCode!="80" || !event.altKey)
{
return true;
}
document.getElementById("a
}
//-->
</SCRIPT>
</head>
<body onkeydown="pCheck();">
<a id="aa" href="javascript:alert('Th
<img src="bin.jpg" name="left" border="0" alt="Click or 'ALT P' for previous page" WIDTH="30" HEIGHT="26"></a>
</body>
</html>
ASKER
That will not work for a web site.. I will have to have a big switch statement to compare all the event keys that I want to trap. I was hoping that the accesskey function would save me that trouble.. except for this problem..
Thanks
Thanks
ACCESSKEY does work in IE.
It seems like only with ALT+P there is a problem.
This workaround will cover this small bug, other ACCESSKEY can be used.
It seems like only with ALT+P there is a problem.
This workaround will cover this small bug, other ACCESSKEY can be used.
ASKER
ALT+P was just a example.. I tried it for quite a few keys and it does not work.
This example seems to work :
<LABEL FOR="fp1" ACCESSKEY="P">#<SPAN style="text-decoration:und erline;">P </SPAN>:
Press Alt+P to set focus to textbox</LABEL>
<INPUT TYPE="text" NAME="T1" VALUE=text1 SIZE="20"
TABINDEX="1" ID="fp1">
with P
<LABEL FOR="fp1" ACCESSKEY="P">#<SPAN style="text-decoration:und
Press Alt+P to set focus to textbox</LABEL>
<INPUT TYPE="text" NAME="T1" VALUE=text1 SIZE="20"
TABINDEX="1" ID="fp1">
with P
ASKER
ALT+P was just a example.. I tried it for quite a few keys and it does not work.
check out this url :
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtmlrefs.asp
What you need to try is :
<INPUT type="button" ACCESSKEY="P" onclick="alert('moshe')">
It seems like the <A> tag does not fire the onclick and just sets the focus.
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtmlrefs.asp
What you need to try is :
<INPUT type="button" ACCESSKEY="P" onclick="alert('moshe')">
It seems like the <A> tag does not fire the onclick and just sets the focus.
ASKER
The problem is probably with invoking Javascript.
It's not a problem.
It's the way ACCESSKEY behaves.
IT doesn't always invoke onclick event, on <A> tag it just set the focus (you can then call the method on the onfocus handler as a work around).
It's the way ACCESSKEY behaves.
IT doesn't always invoke onclick event, on <A> tag it just set the focus (you can then call the method on the onfocus handler as a work around).
ASKER
The problem is probably with invoking Javascript.
ASKER
Netscape 6.2 supports it absolutely fine, so I thought that IE 5 should also have a support for the same.
But I don't understand the problem now.
ASKER
Netscape 6.2 supports it absolutely fine, so I thought that IE 5 should also have a support for the same.
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or so. I appreciate any comments that would help me to make a recommendation.
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
ahosang
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
ahosang
ASKER
None of the above comments worked. So as far as I am concerned, you can DELETE the same.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
answered by avner
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange
lexxwern