...

View Full Version : Assign URL To buttons



Q2004
02-02-2004, 07: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, 07: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?

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

http://www.devguru.com/Technologies/ecmascript/quickref/evhan_onKeyDown.html
http://www.devguru.com/Technologies/ecmascript/quickref/evhan_onKeyPress.html
http://www.devguru.com/Technologies/ecmascript/quickref/evhan_onKeyUp.html

Q2004
02-02-2004, 09: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:

============
<HTML><HEAD></HEAD>
<BODY>
<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>
<br>
<IMG SRC=http://www.jasonanhkhoa.com/Images/Jason/2001/Jason1stMonth/Jason031001_01.jpg></IMG>
</CENTER>
</BODY>
</HTML>
============

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, 10:00 PM
<html>
<head>
<script type="text/javascript">
function checkForArrow(evt)
{
var charCode = (evt) ? evt.which : event.keyCode
if (charCode == 37 || charCode == 38)
document.location.href="http://www.ibm.com";
if (charCode == 39 || charCode == 40)
document.location.href="http://www.netscape.com";
return true;
}
document.onkeydown = checkForArrow;
</script>
</head>
<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>
<br>
<img src="http://www.jasonanhkhoa.com/Images/Jason/2001/Jason1stMonth/Jason031001_01.jpg" />
</body>
</html>


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.

Q2004
02-02-2004, 11:01 PM
Thank you Roy, it's exactly what I want.

:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum