This weekend, while I was out all day, I found myself wanting to respond to questions on my blog and for one of those I needed to check out the source code of the questioner’s website. The ability to view the source code of a web page is easy from your desktop computer, but it’s not built into mobile safari.
Searching for how to do it brought up a few options:
- A bit of a view source round up at iphoneized
- which led me to Shaun Inman’s bookmarklet tool — this one is pretty nice because it, is reasonably easy to bookmark without computer intervention, it has line numbers, and works with copy and paste quite well; the only downside, I thought, was that the line numbers get copied when copying multiple lines
- a bookmarklet by Abe Fettig — this one is a bit more laborious to actually get into your iPhone bookmarks and also doesn’t seem to support copy/paste well (I could only get it to copy the whole page, not individual sections)
- I searched the app store for “view source” and tested all the free apps available to look at web page source code
iSource Browser
iSource was the first one I tried. It has some great ideas and features that the other apps don’t: WHOIS, DIG, and HOST lookup, as well as the ability to email debug info. Other nice (but not necessarily unique) things include browser view, open in Safari, and email source code.
My only gripes with this app are that it doesn’t use the iPhone’s browser/URL keyboard with the convenient .com button, and you have to type in http:// to the address bar: it doesn’t auto-fill that part for you when you press the x to remove the previous contents of the address bar. It also doesn’t have state saving or any bookmark feature, so you have to retype the URL every time you enter the app.
HTML Viewer
HTML Viewer is easily my favourite application of the 4 free ones that were available. It uses the iPhone URL keyboard, it has buttons to quickly switch between browser and code view, switch between line wrapped and non-wrapped code, bookmarks, search(!), and email. You can also add a bookmark in Safari to launch your current page in HTML Viewer.
It doesn’t have state saving, so remember to bookmark your current page if you want to switch to another application. The only thing that doesn’t work as well as I’d like is the copy and paste: it seems you’re stuck with copying one word or everything from the top down, because when you try to drag the select end marks (the way you do on the iPhone to change a selection) suddenly the block of code at the top of the page is selected, rather than the bit you were working with.
iHTML
iHTML is very simple, but works really well if you only need the two main features it has: code viewing and emailing the source code. If you turn the app to landscape view you get a split code/browser view (that’s the only browser view the app has). Copy and paste works smoothly in this app and, unlike the others, it remembers the web page it was on last time it was open. It also uses the URL keyboard and automatically fills in http:// for you, so typing in URLs is pretty quick.
Web Source Viewer
Web Source Viewer is the simplest app of the lot. It only uses the landscape orientation, and has no extra features other than viewing and copying the source code of a page. It does use the URL keyboard, but has no quick way to delete the URL from the address bar, it doesn’t auto-fill http:// for you, and it has no state saving.
I wouldn’t really recommend this one as it doesn’t seem to be under current development. The only reason I can see that you would pick this app over any of the others is if landscape view and copy/paste are really important at the time since iSource doesn’t do landscape view, HTML Viewer has a full landscape view, but copying is buggy, and iHTML doesn’t have a full landscape view.
nisa sanjaya says
this is very nice .. your post very helpfull to me. thanks 🙂
Banii says
A very useful tip!
Coca Del Atoris says
Very nice find,
Tom says
Merci, now I can copy some code and email it to myself 🙂
David says
Is there a way to view the source code of an HTML email on my iPad or iPhone?
kristarella says
David — As far as I know there is no way to do it with the iPhone Mail app. If you’re using Gmail, you can access your account via Mailroom and there is a “View…” button in the top right when viewing a message. Selecting “View Original” gives you the plain text source of the email.
David says
Thanks Kristarella. I was able to figure out how to do it. There is an app called HTML Editor that is made to create HTML emails to send out. All I do is copy and paste the content of the body of an HTML email into the HTML Editor and it gives me an option to paste it as HTML. And there it is. I can manipulate it and then copy that code into the app called FTP On The Go and save it as an html file and post it to my website and use it as a webpage on my website.
kristarella says
David — Awesome! Thanks for sharing 🙂
JJ McConnachie says
Thanks so much! This is very helpful – just what I needed!