Forum Moderators: open

Message Too Old, No Replies

Hide hyperlinks in source code

How to?

         

Widestrides

7:46 pm on May 1, 2009 (gmt 0)

10+ Year Member



I have a simple HTML resource site with many outbound links. I don't want someone to easily come in and copy all the links which I painstakingly put together and just duplicate my site.

I know they could copy them one by one, but if there is a way I can hide them in my source code to at least make it more time consuming for them to rip me off, I'd like to do it.

Any way to do it in simple HTML? Or would I have to go to CSS or XHTML or XML?

Thanks!

tangor

9:03 pm on May 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Anything that appears in HTML code is viewable. I haven't done it, but you could serve those links via serverside programming which will make it more difficult to collect... though they can still be collected just by clicking. Only way to keep a secret is not to reveal it!

penders

4:37 pm on May 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yeah, even if you try to obfuscate your HTML by using numerical entity references etc - your source will be harder to read, but they could still simply copy your code into their own page and it will work.

As tangor suggests you could use a server-side script to manage your links. EG:

<a href="gotopage.php?id=8274">Goto another site</a>

gotopage.php would be a script on your server that knows that id=8274 refers to www.example.com and could redirect the browser. The script would only work if called from your server (otherwise someone could simply copy your source and modify the path to gotopage.php). The script could also keep track of the number of click-throughs etc.

penders

11:46 am on May 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<a href="gotopage.php?id=8274">Goto another site</a>

Just to add... Slight caveat... This approach does kinda break a few (useful) things in the browser. The context (right mouse) menu options to "Copy Link Location", "Send Link...", "Bookmark This Link..." etc. (Firefox) might not work anymore and some (suspicious) users may not like the fact that the true destination of the link is obfuscated in this way.

brodyh

12:43 am on May 11, 2009 (gmt 0)

10+ Year Member



You could also use a JavaScript file to do this.. though they could just look at the source of your JavaScript file.

HTML Document:

<script type="text/javascript">document.write(MakeLink(8274));</script>

JavaScript Document:

function MakeLink(LinkID) {
if (LinkID == 8274)
return "http://example.com";
}
else if (LinkID == 8275) {
return "http://nowhere.com";
}
else {
throw "Function MakeLink; unable to return valid link, as argument LinkID was undefined.";
return "/Fake-Error404";
}
}

Unfortunately using JavaScript for making links is also kind of shady. It's suspicious and doesn't work well in non-JavaScript browers. However, it will make it difficult for someone to just copy the links, and like @penders said it will appear to the browser as a normal link, so those features of the browser will still work.

Oh and just a note: If you're going to use the 'aplication/xhtml+xml' mimetype make sure to use a CDATA tag in the <script> area.