Read XKCD on the iPhone .. Finally

I always want to read the great web comic XKCD when I’m on the go, but alas half the humor is in each comic’s HTML image title attribute which the iPhone won’t let me see.

Thus I present you with a solution: A nice little bookmarklet you can run when viewing an XKCD comic (or any other page with images with title attributes), and it will show you the title in an alert.

(It chooses longest image title on page to show you which is usually what you want.)

XKCD Image Title Attribute Viewer Bookmarklet

Here is the version of the bookmarklet install on your iPhone (The page it opens will give you further instructions on installing):
ShowImageTitles (iPhone version)

Here is the version for a standard browser. Just drag it into your toolbar:
ShowImageTitle

Here’s the nicely formatted source in case you want to modify it:

function get_img_w_longest_title(){
	var imgs = document.getElementsByTagName('img');
	max_title_length=0;
	max_img = '';
	for (var i=0; i<imgs .length; i++) {
		if (imgs[i].title.length > max_title_length) {
			max_title_length=imgs[i].title.length;
			max_img = imgs[i];
		}
	}
	return max_img;
}
alert(get_img_w_longest_title().title);

and I used this handy converter to turn that source into a functioning one line bookmarklet.

Enjoy!

del.icio.us |  Digg |  FURL |  Yahoo! My Web 2.0 |  Reddit

Leave a Reply