The Mint Easter Egg and Making Your Own Javascript Easter Egg

Nov
02
2005

You may have read or seen the "easter egg" that's in the Mint stats package that pops up a graphic when you enter the Konami Nintendo cheat code. I figured some people might like to know how to do their own in a similar fashion. It's only coded for IE, but you'd only have to adjust for the Mozilla event model instead or together. However, only using the one browser makes for a simpler explanation.

Below is the entirety of a demo of how to do this. The simplest way to use it to build your own is to save it to an HTML file, open it in IE. Type the series of keystrokes you'd like as your easter egg trigger and hit the "Reveal" button. The series of numbers you see are your numbers to put into $eastereggcode. What's in there now is "UP UP DOWN DOWN LEFT RIGHT LEFT RIGHT B A", using the arrow keys for the directions. This sample just does a window.alert(), but whatever effect you want would go in that spot if you'd like a more elaborate result.

Your deployed script doesn't need the reveal() function. Otherwise, you just need to put your snippet into the page and wait for people to discover. Or, leak the information like every other good easter egg and enjoy.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
<!--
var $keystrokes = "";
var $eastereggcode = "38 38 40 40 37 39 37 39 66 65";
function log_keystrokes($event){
//ie only
$keycode = $event.keyCode;
$keystrokes = $keystrokes + $keycode + " ";
$match = $keystrokes.indexOf($eastereggcode);
if($match > -1){
window.alert("easter egg");
$keystrokes = "";
}
}
function reveal(){
document.write($keystrokes);
}
//-->
</script>
</head>
<body onkeydown="log_keystrokes(event);">
<button onclick="reveal();">Reveal</button>
</body>
</html>

easter egg, mint, javascript, web development, fun

 

Comments on this post

Feedback is always welcome. Read some from other folks or leave your own below. Just keep things civil and remember that what you post lives on in public. Forever.

Thanks,
J

2 Responses to “The Mint Easter Egg and Making Your Own Javascript Easter Egg”

  1. Beth Says:

    Hmm I may have to try this when I put up my new page…

  2. Julien Fabre Says:

    Man, thanks for the code, it gived me some cool ideas for the credits of the websites i code! :)

Leave Your Own Comment

By submitting a comment, you agree to license it under the terms of the Creative Commons Attribution license.

People who post comments get the added benefit of visiting the site without advertising.

© 2003-2008 J Wynia. All original content is licensed under the terms of the Creative Commons Attribution license unless otherwise noted. Content from other sources is licensed under its original terms.