Learned this trick while on a client call today. Meat of the article is posted below as well for posterity.
—
How to Install a Bookmarklet on Mobile Safari
Navigate to this page on your iPad and select “Add Bookmark”. Change the name of the bookmark to “View Source” or whatever you like. Tap “Save”.
Next, copy the bookmarklet from here. (Select All > Copy.)
Lastly, go to your bookmarks, tap “Edit”, select the bookmark you just created, and replace the URL by pasting in the new code. Tap “Done” and you’re done.A few things:
- The source you’ll see is the DOM source (“generated source”), not the original HTML source.
- The ends of some very long strings are partly hidden from view.
- It works well on the iPad but on the iPhone the text wrapping does not work as well (the ends of more lines are cut off).
- It should work in any browser that supports the white-space value pre-wrap. But I’ve only tested on iPad, iPhone, and Opera Mini on the iPhone.
- For some reason the source code output is not fully selectable. You can Select All but you cannot define segments to select.