Powered by KikBooks Widget

By on June 2, 2007, with 31 Comments

You probably noticed a strange ribbon at the top of the page, in the left upper corner, that says “Random Illusion!”. Well, I think it is wonderful add-on for Mighty Optical Illusions. If you click that button, it will take you to one random illusion from our archives of over 1000 illusion articles.

What is so interesting about it, is that you never know what to expect! I couldn’t stop clicking it, and every time the page loaded, I was surprised seeing illusion I forgot I already posted :) I tried this so many times to see if some articles will re-appear twice, but I never managed. Go ahead, test it and if you get some articles re-appear twice, post in comments. I believe this add-on works in all web browsers. I tested it with Firefox and with Internet Explorer, but just in case I would appreciate if you commented your experience with different resolutions and different browsers. Also, I’m interested in your opinion, if the button is too intrusive. I believe all of you will adore it, but if for some reason many of you dislike this option, I shall remove it.

If you also use blogger platform for blogging, and want to implement “Random post” hack, you can do it easily by following these instructions (continued inside this article)…


1.) First, add the following javascript to your page’s header between head and /head tags. (Template -> Edit HTML):

<script type="text/javascript">
//<![CDATA[
var _yourBlogUrl = "http://www.moillusions.com";

function randomPost() {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
var theUrl = _yourBlogUrl +"/feeds/posts/summary?alt=json-in-script&callback=getTotalPostsCallback&start-index=1&max-results=1";
script.setAttribute("src", theUrl);
document.documentElement.firstChild.appendChild(script);
};
function getTotalPostsCallback(json) {
var totalResults = json.feed.openSearch$totalResults.$t;
if (totalResults > 0) {
getRandomPostNumber(totalResults);
}
};
function getRandomPostNumber(totalResults) {
var randomNumber = Math.floor((Math.random() * totalResults) + 1);
getRandomUrl(randomNumber);
};
function getRandomUrl(randomNumber) {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
var theUrl = _yourBlogUrl +"/feeds/posts/summary?alt=json-in-script&callback=getTheUrlCallback&start-index=" + randomNumber + "&max-results=1";
script.setAttribute("src", theUrl);
document.documentElement.firstChild.appendChild(script);
};
function getTheUrlCallback(json) {
var theUrl = json.feed.entry[0].link[0].href;
window.location.href = theUrl;
}
//]]>
</script>

Make sure to replace the _yourBlogUrl variable with your blog’s URL, and just add the following link anywhere in your page:

<a href="javascript:randomPost();">View Random Post</a>

Since this uses JSON feed callbacks, you’ll need to make sure that you (at the very least) have summary feeds enabled for your blog. Many thanks goes to Janek37 for inspiring me to do this, and providing helpful tutorial.

  • the person

    Awesome addition! You wondered whether it worked with all web browsers and I know it does work in Safari. I can’t stop clicking it!

    • http://google.com ross

      awsome :D

  • The Wolfgirl Liberation

    I love this site and visit it every day. I’d love to know how to add that random illusion ribbon onto my Myspace so people can click on it too,does anybody have any idea how???
    http://www.Myspace/thewolfgirlliberation

  • Anonymous

    It works on Opera, just so you know – and I think it’s great; I’ve found lots entries which I’ve not seen before. And it’s also great ’cause some of us (including myself) are too lazy to wander through the different catergories ^^

  • Luke

    Umm, Vurdlak, i clicked 5 times and ‘the devil is coming’ came up twice! When are you going to post my post!

  • Chris

    i clicked on the ribbon 3 times and got the puzzled hunter twice in a row!

    btw, it works on safari

  • Anonymous

    at one point the button just started giving me the same thing over and over again as if were hitting refresh. it doesnt work properly for firefox

  • Ashok

    Does nobody care about the actual illusion here? :P

    Its so cool, I didn’t expect that and it took ages for me to find it…

  • Anonymous

    Sweet illusion…(hint- look unfocused at the middle of the world).
    This took me about 3 min to find

  • Anonymous

    #6 was wrong, i’ve got Firefox and it works perfectly

  • kenia

    it works on MSN explorer! Oh, and that illusion to the left is awesome! with the woman and the globe!

  • Anonymous

    Awesome illusion. At first I thought Australia was a nose in a cartoony face, but that’s not the illusion. Now I see the real illusion. Is everything geographically correct? It’s pretty cool.

  • Anonymous

    so… i tried it in safari 2.0.4 and it worked prefectly, and i also tried it in (brace yourself for this one people) internet explorer 5.2.3. it didnt work in internet explorer cuz i didnt have the right plug-in, but… i dont think thats too big of a loss…

  • Anonymous

    The line

    window.location.href = theUrl;

    would normally add a new entry to the browser history (as opposed to location.replace which would replace the current page with a new page). So, after clicking five times I’d expect to be able to go back five pages well. But somehow using the Ajax callbacks this does not work. In other words: it seems impossible to go back in the page history. Same behavior in Firefox, Safari and Camino on Mac OS X.

    Too bad the history doesn’t work, but a nice addition anyhow!

    Adrian.

  • Anonymous

    Great illusion.. though i have to admit i had to look again to not see the face lol

  • Anonymous

    the illusions like others…
    A hidden picture..

  • King Smily

    Great addition! I have been hoping for something like this for a while! Now the trick will be getting me to stop clicking on it…

  • Walt

    Excellent hack, thanks for sharing.

  • Eddie

    WOAH!!! I got the same one twice!

  • Anonymous

    I saw an illusion twice with he random illusions thing only.

  • rzam0

    i got this page twice with random illusion thingy

  • Anonymous

    Has anyone notice that there already is a ‘Next Random Illusion’ button between the illusions and the comments section. That’s what I’ve been clicking since day one. When I want to look at something specific then I go to the sidebar. And it’s at a good spot, so that when you scroll down viewing the illusion there it be. And it’s right above the Add your comment button to boot.

    P.S. I love this site!

  • Sytze

    Guess how i came to this page…
    With the random button!
    :-P

  • Anonymous

    This one of my most favorite application on facebook.
    I don’t want to hurt your feelings but it only took me a few minutes to find the owl.
    Yes I do use the widget.

  • Aish

    I use that upper “random illusion” button and the other one, too, and this same page came up twice! thats ok, though. The random buttons are great idea.

    I like the illusion. The map of the world seems abstract/distorted, especially where the lady’s face appears, but it is COOL visual effect! =D

  • Genius

    I once got the same optical illusion randomly 3 times in a row, and another time twice o.O I’m always getting the same illusion over and over again. Not always in a row, but very often.

  • http://www.youtube.com someone

    huh?

  • anonymous someone

    tis is truely amazing! :)

  • Special ED

    Whoa, that’s awesome.

  • Annishia

    umm acually… i got to THIS post by the button!

  • pokemon boy1

    i got this 1 then scary illusion 4, then this again!!

Pinterest