Ph.Creative is a full service design and communications agency specialising in web design, SEO, internet marketing and branding.

Liverpool

London

Manchester

New York

Call us on +44(0)151 708 2280 or liverpool@ph-creative.com

Call us on +44(0)20 3301 4503 or london@ph-creative.com

Call us on +44(0)161 880 0122 or manchester@ph-creative.com

Call us on (001) 646 340 1025 or newyork@ph-creative.com

jQuery Trick: Hidden Links

by Craig Wilson 30 March 2009 at 10:31

Sorry, I know the name sounds like a poor attempt at some black hat SEO, but that’s not the case (I just can’t think of a better name for it.) Remember my hidden message CSS trick? This is a jQuery trick in the same theme. With this, you can hide links within links, so by default they go to any normal page, but contain a hidden link on double click – taking your in the know visitors to a secret page.

It’s all very easy to set up. First, create your normal link.

<a href="http://www.google.com">Google.com</a>
Then we’re going to give it an ID for our jQuery code.
<a id="hiddenLink" href="http://www.google.com">Google.com</a>
We’re going to use jQuery’s click and dblclick events for this. So first we’ll go ahead and set up the single click event first.
$("a#hiddenLink").click(function(){
  var timeout = setTimeout(function() {
    location.href=$("a#hiddenLink").attr("href");
  }, 500);
  return false;
});
As you can see, we have to set up a single click event to delay your browser from immediately visiting the href link. We’re only delaying it by half a second, not enough time to notice a delay but just enough time to get that double click in.

So now we’ll set up the double click event, which will contain the URL to your secret page.

$("a#hiddenLink").dblclick(function(){
  location.href="http://wikipedia.org";
});
And that’s it! Click here for a demo (or double click for some fun.)

Currently rated 4.4 by 7 people

  • Currently 4.428571/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

web design | Web Technologies | jquery

Comments

Comments are closed
 

Search

Recent Comments

Comment RSS

© Copyright Ph.Creative 2009. All rights reserved. Terms & Conditions | Privacy Policy | Sitemap (XML) | Log in

Website design by Ph.Creative

^