My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://www.mattdturner.com/wordpress
and update your bookmarks.

AdSense

Pages

Friday, April 22, 2011

How to View HTML Source Code on iOS | iPad, iPhone, iPod

Occasionally, when browsing the web I have a need to view the source code for a certain page.  However, there is no intrinsic way to do so on the iOS version of safari.  Well, using some simple javascript bookmark you can view the source code for any webpage.

To view the source code, follow the below instructions:

  1. Open Safari (duh!)
  2. Click the "Add Bookmark" button in Safari.
  3. Give the bookmark whatever name you wish; I chose the title "View Source".
  4. In the address bar of your new bookmark, paste the following code: 
    javascript:var%20sourceWindow%20%3D%20window.open%28%27about%3Ablank%27%29%3B%20%0Avar%20newDoc%20%3D%20sourceWindow.document%3B%20%0AnewDoc.open%28%29%3B%20%0AnewDoc.write%28%27%3Chtml%3E%3Chead%3E%3Ctitle%3ESource%20of%20%27%20%2B%20document.location.href%20%2B%20%27%3C/title%3E%3C/head%3E%3Cbody%3E%3C/body%3E%3C/html%3E%27%29%3B%20%0AnewDoc.close%28%29%3B%20%0Avar%20pre%20%3D%20newDoc.body.appendChild%28newDoc.createElement%28%22pre%22%29%29%3B%20%0Apre.appendChild%28newDoc.createTextNode%28document.documentElement.innerHTML%29%29%3B
  5. Now just navigate to whichever page you wish to view the source of, click the bookmarks button, and select your new View Source bookmark.
NOTE: I did not create this javascript bookmark.  I only discovered it while browsing the internet.  For the source of the javascript bookmark, please see Rob's Blog.

0 comments:

Post a Comment