View Full Version : Assign URL To buttons

02-02-2004, 08:03 PM
Please Help,
I have hundreds of HTML pages, each has Prev & Next icons
(image) to link to the prev/next HTML page. Instead of these
icons, I want to assign the Left & Right Arrow keys to be bring up
the Prev/next HTML page.

Anyone know how to do this?

Roy Sinclair
02-02-2004, 08:44 PM
You'll need some Javascript to capture the use of the left and right arrow keys (probably should capture up and down arrow keys as well) and perform the right action when they occur.

Can you take it from here or do you need help with the javascript?

02-02-2004, 08:45 PM
I think that this is more of a javascript question. Try the following links to get started.


02-02-2004, 10:42 PM
I'm still new at javascript, so if you please, add the code taht would make it work for me. Here's my HTML code:


<A HREF=http://www.ibm.com TARGET=body3><img SRC=http://www.jasonanhkhoa.com/Images/left-arrow-rainbow.gif width=30></a>

<A HREF=http://www.netscape.com TARGET=body3><img SRC=http://www.jasonanhkhoa.com/Images/ri-arrow-rainbow.gif width=30></a>
<IMG SRC=http://www.jasonanhkhoa.com/Images/Jason/2001/Jason1stMonth/Jason031001_01.jpg></IMG>

I want to have the ibm link page come up when left-arrow-key hit and netscape link page come up when ri-arrow-key hit.

Roy Sinclair
02-02-2004, 11:00 PM
<script type="text/javascript">
function checkForArrow(evt)
var charCode = (evt) ? evt.which : event.keyCode
if (charCode == 37 || charCode == 38)
if (charCode == 39 || charCode == 40)
return true;
document.onkeydown = checkForArrow;
<body style="text-align: center;">
<a href="http://www.ibm.com" target="body3"><img src="http://www.jasonanhkhoa.com/Images/left-arrow-rainbow.gif" width="30"></a>
<a href="http://www.netscape.com" target="body3"><img src="http://www.jasonanhkhoa.com/Images/ri-arrow-rainbow.gif" width="30"></a>
<img src="http://www.jasonanhkhoa.com/Images/Jason/2001/Jason1stMonth/Jason031001_01.jpg" />

This code also works for the "up" and "down" arrows. Just from the gist of what I saw while working on this you might want to search this forum for advice on "slide show" scripts. You might find something you'll like better.

02-03-2004, 12:01 AM
Thank you Roy, it's exactly what I want.