Sometime ago, I had the idea of building a gadget named RandomMe. Under this, there is a button on the side bar, and whenever the user would click on it, a random page from the site of his choice would open up. The sites are restricted to those with url, which when called redirect you to a random page, like one on Wikipedia, http://en.wikipedia.org/wiki/Special:Random, that redirects you to a random article.

I managed to get the button and the flyout working. When the button is clicked, the flyout opens, and in an iframe shows the random page from Wikipedia. The problem with this is that the whole webpage is shown. What I wanted to do was this, whenever a user would click on the button, the first part of the description (just simple text), plus an image would be shown. To this end, I fiddled around with numerous methods, mostly XMLHttpRequest, but after the eval of the responseText I'm stuck.

Also, if like the user wishes to see the strips at xkcd.com, then only the comic strip should be shown and nothing more, except maybe sharing options.

I am not able to extract the data in the responseText, let alone use it. Also, while the flyout is open, if the button is clicked once more, the flyout should show a different random article.

The code i'm currently using, that calls the webpage in the iframe is as follows: