F1 key to go to a link

S

Sue

Hi,

I'm new to javascript and what I want to do is when user press F1 key,
it will show the help page. Can anyone show me the javascript code.
The link of the help page is help/work/Default_CSH.htm#messageBar
Thanks.
 
E

Evertjan.

Sue wrote on 26 okt 2007 in comp.lang.javascript:
I'm new to javascript and what I want to do is when user press F1 key,
it will show the help page. Can anyone show me the javascript code.
The link of the help page is help/work/Default_CSH.htm#messageBar
Thanks.

Seems you are new to this NG to, as this was discussed some time ago.

It is impossible with clientside javascript on a browser.
 
T

Thomas 'PointedEars' Lahn

Sue said:
[...] what I want to do is when user press F1 key, it will show the
help page.

It already does show the help page ... of the browser. And that is good so.
Can anyone show me the javascript code.

You don't need any code for that, let alone "javascript" code.
The link of the help page is help/work/Default_CSH.htm#messageBar

Include an <a ... accesskey="h">Help</help> or something like that instead.
Users don't take kindly on their browser being broken by authors who think
they know better.


PointedEars
 
D

David Mark

Hi,

I'm new to javascript and what I want to do is when user press F1 key,
it will show the help page. Can anyone show me the javascript code.
The link of the help page is help/work/Default_CSH.htm#messageBar
Thanks.

It isn't a good idea, but this works in most browsers:

this.onload = function() {
var doc = this.document;
if (!doc) { return; }
doc.onhelp = function() { window.open('help/work/
Default_CSH.htm#messageBar'); return false; };
doc.onkeydown = function(e) { if (e && e.which == 112)
{ window.open('help/work/Default_CSH.htm#messageBar'); return
false; } };
doc = null;
};

Normally onkeyup would be the appropriate event, but to prevent the
browser's help window from opening, you have to use onkeydown (or
onhelp for IE.) Opera will navigate to its help page in any event,
just as it will always show its default context menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top