MobileSafari ViewS

Inspired by Anthony Piraino’s iSource (which in turn was inspired by a tweet from Mr. Cederholm) that I linked earlier today, I decided to take a whack at adding the improvements mentioned.

Choosing a monospace typeface caused MobileSafari to arbitrarily resize text elements so I can see why Anthony didn’t bother with it. Unable to quickly identify the source of that problem, I set it aside for now.

My primary feature request was a way to pass a url as part of the query string—which would make creating a JavaScript bookmark feasible.

In addition to providing a bookmark, my version, ViewS, adopts the user-agent provided by your browser for the request so you can be sure that you are viewing the actual source that the browser is rendering (compare google.com using both tools in Mobile Safari, iSource shows the source code served to desktop browsers—not mobile devices). ViewS follows redirects and sets the content-type of the page based on http headers and meta tags from the viewed source. It also automatically adds .com if the url doesn’t already contain a period.

The syntax of this JavaScript bookmark cuts some corners in the interest of brevity but it works:

javascript:location='http://shauninman.com/vs/?url='+escape(location)

The easiest way to add it to your Bookmarks in MobileSafari is to visit and bookmark this url. Once saved you can edit the url portion, adding javascript:location=' before and '+escape(location) after (don’t forget the single quotes).

Previous
iSource
Next
Enjoy the ViewS
Author
Shaun Inman
Posted
November 16th, 2007 at 2:35 pm
Categories
Apple
Web
Comments
007 (Now closed)

007 Comments

001

This is great. The bookmarklet makes it much more convenient. Now I can geek out in source view on the go.

Author
Rob Goodlatte
Posted
Nov 16th, 2007 5:05 pm
002

Thanks for the link Shaun! The querystring and bookmarklet combo is a great idea - I’m going to try to add that tonight.

Author
Anthony
Posted
Nov 16th, 2007 6:21 pm
003

Use

javascript:location='http://shauninman.com/vs/?url='+escape(location)

for URLs with special characters.

Author
Ben Alpert
Posted
Nov 16th, 2007 6:23 pm
004

Ok, I’ve added query-stringiness and bookmarkletability to iSource. I also reworked how I retrieve the target file, and am now adopting the browser’s user agent as well - google.com should look the same in iSource and ViewS.

I actually didn’t try a monospaced typeface yet - it was on my list of things to take a look at, but I haven’t had a chance to do so. I’m not sure why it would freak things out like that.

Author
Anthony
Posted
Nov 17th, 2007 1:02 am
005

Brilliant. It would be nice if the stylesheet href was a link so that we could see that within ViewS also, without having to type that URL into the input box. I’m super lazy!

Author
Sam Brown
Posted
Nov 19th, 2007 9:45 am
006

Killer idea Sam. Done.

ViewS now automatically creates links from src and href attributes to simplify viewing external CSS and JavaScript source—as well as embedded images.

Author
Shaun Inman
Posted
Nov 19th, 2007 10:56 am
007

Sweet! I really missed being able to view source on the iPhone. I even got dissed for not being able to do that just this weekend.

Author
eystein
Posted
Nov 19th, 2007 7:06 pm