开发者

"Easter Egg" in link - activated by CTRL + click

I'm working on a project for a client, and we want to make a easter egg, when you click some of the letters in the logo.

There are three letters, an开发者_运维百科d you have to click in the right order, before it activates the easter egg. However, because it's in a link, I wondered if I could use CTRL+Click...? I've searched the web, but couldn't get any answers...


Sure, you can do that

<html>
<head>
  <title>Test Page</title>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript">

  $(function(){
    $('#link').click( function( event )
    {
      if ( event.ctrlKey )
      {
        event.preventDefault();
      }
    });
  });

  </script>
</head>

<body>

<a href="http://www.google.com" id="link">Google</a>

</body>
</html>

You'll need to add your own logic to track the sequence of clicks on the three letters.


The link could work, just have it execute a JavaScript method on the click rather than navigate to a page. Since you mentioned that there needs to be an order to the clicks, just have some variable's state transition based on the click sent.

<script type="text/javascript">

var track = 0;

function click_this(val) 
{
  // Manage your state here
}

</script>

T<a href="javascript:click_this(1);">e</a><a href="javascript:click_this(2);">s</a><a href="javascript:click_this(3);">t</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜