
Originally Posted by
ruffneck119
I have looked all over no one has a solid script to hide a link using
JS. I used this code but it will not open in the same window. Can anyone help me make it open in the same window? Or do you have your own code to hide links from Google?
Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function url() {
hidden = open('http://www.url.com');
}
// End -->
</script>
<A HREF="javascript:url()" ><IMG SRC="image.jpg" border="0"></A>
I'm a little curious as to why you'd want to hide links from google but couldn't you just put it in the robots.txt file so it doesn't crawl it? Or use a short link service. I can understand the need to 'cloak' links from the public tho' so those doing a mouse hover get a different url to actually clicking a link, to hide affiliate ID's for instance. JavaScript isn't needed for that, I have my own way if it's any use to you:
Code:
<a title="Click Here" href="http://www.google.com" onClick="this.href='http://www.yahoo.com'" target="_blank">Click Here</a>
The above for instance would give a mouse over url for google but go to yahoo when clicked. If you use an affiliate ID then the plain url in the first link (for mouse over url) and the aff ID in the second link (to be visited). Take out the target="_blank" to open in the same window.
It works for me and it's simple (I like simple) plus it works without JavaScript so it works if Java is off.
Alternatively - you could link to a redirect page in a sub folder and hide the sub folder with robots.txt, that might work, then you could do a meta redirect (index.html) or have a php redirect (index.php).
index.html redirect:
Code:
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://www.domain.tld" />
</head>
<body>Loading...</body></html>
index.php redirect:
Code:
<?php
header('Location:http://www.domain.tld');
?>
Or there's plan 'B' where you could redirect to a blank(ish) sub folder and have an .htaccess 301 redirect, but maybe I'm just thinking too much now.
Bookmarks