How to “View Source” from Safari on an iPad or iPhone

View Source on an iPad or iPhone

Ever wanted to view source of a webpage from an iPad or iPhone? Unfortunately, mobile Safari doesn’t include the feature on it’s own, but with the help of a custom bookmarklet you can view source of any web page right in iOS. This awesome tip comes from Michelsen.dk, and here’s how to set it up:

Bookmark this page (or any other) with Safari on an iPad, iPhone, or iPod touch and name it “View Source”
Click here to view the bookmarklet javascript and Select All -> Copy
Tap the Bookmark icon at the Safari new browser screen and tap on “Edit”, then tap the bookmark you saved in step 1
Paste the javascript code you copied in step 2 into the URL bar and save the changes by tapping “Done”

Now when you want to view a web pages source, open the Bookmarks menu and select “View Source”, the source code will appear in highlighted syntax with clickable source urls.

One thing to note is that the javascript being used here sends the page to the michelsen.dk server for processing, if you’re not comfortable with that there are other solutions out there but they won’t highlight the syntax and aren’t nearly as elegant overall.

A similar tip utilizes an edited bookmark to let you run Firebug with Mobile Safari on an iPhone or iPad too, which may be a bit more useful for developers.

Found via ShawnBlanc on Twitter, you can follow us there too