...

View Full Version : Link manipulating?



Willi
02-12-2007, 04:00 PM
Hi there,

just one short question for a JS newbie:

I want to manipulate a normal href link with the onClick event.
<a href="http://anywhere.com" onClick="action()">Link</a>

The browser request should look like:
'http://mypage.com/check.php?url=http://anywhere.com'

In short: I want to attach a string (http://mypage.com/check.php?url=) to the url. But it's manadatory that the href tag (href="http://anywhere.com") stays! Is this even possible? I don't think so!?

Any help or tips are appreciated! THANK YOU! :)

wilwinva
02-12-2007, 04:22 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>test</title>
<script type="text/javascript" >
function action(me)
{
me.href="http://mypage.com/check.php?url="+me.href;
}
</script>
</head>
<body>
<a href="http://anywhere.com" onClick="action(this);">Link</a>
</body>
</html>

Willi
02-12-2007, 10:20 PM
Great! Thank you! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum