The Dopefly Tech Blog

« The Dopefly Tech Blog Main page

Programmers, Prepare Your Pranks!

posted under category: General on March 30, 2005 at 2:00 am by Nathan

As a friendly reminder that April Fool's Day is just around the corner, and better yet, it's a weekday, for those of you who run any intranets, here's a little code to get you going. Just a simple little trick, but it gets the job done. Click below to view it (just a little CF, mostly Javascript).


<cfif not dateCompare(now(),"4/1/#year(now())#","d")>
<script>
var r = Math.round(Math.random()*100);
function dang() {if(r==25){document.bgColor=getRandColor();setTimeout("dang();",50);}}
function getRandHex() {var b16=new Array(1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f');return b16[Math.floor(Math.random()*15)];}
function getRandColor() {var c="";while(c.length<6){c+=getRandHex();}return c;}
document.onload=dang();
</script>
</cfif>

Try it out. Doesn't do anything? There's a 1% chance that it will, but once or so out of a hundred hits, you'll get a random color flashing page background. Refresh and it's gone! Pretty sneaky, no?