Forum Moderators: open

Message Too Old, No Replies

Gather Link from an ID is it possible?

for use with aHotkeys script

         

cunningmark

1:55 pm on Feb 21, 2005 (gmt 0)

10+ Year Member



I have a Hotkeys script, single button shortcut keys for my site, which works well on the navigation elements, but I would like to expand so that links within the pages can have a keyboard shortcut.
Rather than specifying each individual link (which would change in each page) I was wondering if the getelement ('id_NAME') could be modded to work.

This is an info site for a closed till type network, consiting of over 2500 pages designed for a 9" screen.

This script is called from each page (The parent.header.moveForward.... part is to create an array so that it could be navigated backwards (The History Nav has been system disabled on the target network)

var mykey;

if (window.Event){
document.captureEvents(Event.KEYDOWN);
}

document.onkeydown = myKeyDown;

function myKeyDown(e){

if (window.Event){
mykey = e.which;
alert(mykey);
}
else{
mykey = event.keyCode
}

mykey = String.fromCharCode(mykey);

if ((mykey == "i") ¦¦ (mykey == "I")) { parent.header.moveForward(location.href,"../index.html"); }
if ((mykey == "c") ¦¦ (mykey == "C")) { parent.header.moveForward(location.href,"../countries.html"); }
if ((mykey == "b") ¦¦ (mykey == "B")) { parent.header.moveForward(location.href,"../bfpo/bfpo.html"); }
if ((mykey == "f") ¦¦ (mykey == "F")) { parent.header.setActiveStyleSheet("large");parent.main.focus()}
}

another point to note is all my links are in the format:
<a style='cursor:hand' onclick='parent.header.moveForward(location.href,"NAME_OF_FILE.html")'>
this is so that they get added to the array and can then be rewound.

I hope some one can help on this.

I also seem to be having touble with the keypress/accesskey comand in that it wont work either (this is not the prefered option but if the hotkey solution wont work and I can this to work then I will go with it.)

cunningmark

12:19 pm on Feb 22, 2005 (gmt 0)

10+ Year Member



I forgot to spell out the main reason for this posting:

Is it possible to grab the link on the page from its ID or Name.
Reason:
So that i can reference the next button (real link - which would be different on each page) with a shortcut key if they shared the same ID/NAME.
I.e. the script finds the link from the id and goes there.
In the shortcut script, have some thing like (which dont work):
if ((mykey == "x") ¦¦ (mykey == "X")) { Document.replace.getobjectID (letterX)}