Random Illusion Hack!

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">
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);
function getTotalPostsCallback(json) {
var totalResults = json.feed.openSearch$totalResults.$t;
if (totalResults > 0) {
function getRandomPostNumber(totalResults) {
var randomNumber = Math.floor((Math.random() * totalResults) + 1);
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);
function getTheUrlCallback(json) {
var theUrl = json.feed.entry[0].link[0].href;
window.location.href = theUrl;

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.

31 Replies to “Random Illusion Hack!”

  1. 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!

  2. 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 ^^

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

  4. 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

  5. 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…

  6. 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.

  7. 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…

  8. 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!


  9. 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…

  10. 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!

  11. 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.

  12. 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

  13. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *