...

View Full Version : javascript as a link



Antoniohawk
10-26-2003, 01:46 AM
I have the following code to change an image onMouseDown. I was wondering if it was possible to have the browser go to www.google.com onMouseUp. I dont want to have to use a "<a>" because of the little border that it produces.



<html>
<head>
<script language="JavaScript">
<!--
// PRELOADING IMAGES
if (document.images) {
img_on =new Image(); img_on.src ="splashDown.gif";
img_off=new Image(); img_off.src="splashUp.gif";
}

function handlePress() {
if (document.images) document.imgName.src=img_on.src;
}

function handleRelease() {
if (document.images) document.imgName.src=img_off.src;
}

//-->
</script>
</head>
<body>
<div onMouseDown="handlePress()" onMouseUp="handleRelease()">
<img src="splashUp.gif" border="0" name="imgName">
</div>
</body>
</html>

Phip
10-26-2003, 02:56 AM
Add onClick="window.location='http://domain.com/'" to the <img /> tag.

<img src="splashUp.gif" border="0" name="imgName" onClick="window.location='http://domain.com/'">

liorean
10-26-2003, 01:44 PM
Use the a element but add this to your stylesheets:
a img{
border-style: none;
}

Antoniohawk
10-26-2003, 09:42 PM
Phip ur idea works great. I tried using the <a> + the style and the border still was there when i clicked. Not sure if i did something wrong.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum