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: The entire code should be on a single line. 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.
Enhanced by Zemanta

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

  1. […] Finding Text on Any Website on the iPad, iPhone, and iPod by Admin on Apr.25, 2011, under iPad, iPhone One rather frustrating thing that I have noticed with the iPad (and iPhone) is the inability to search for text within Safari.  Well as it turns out, a simple javascript bookmark is all you need to add this functionality to any iOS device (just like my post on viewing source code). […]

  2. Fat Loss 4 Idiots

    Your blog is so informative … keep up the good work!!!!

  3. Skin DM Wrinkles

    Hi. I needed to drop you a quick be aware to express my thanks. Ive been following your weblog for a month or so and have picked up a ton of good data and loved the tactic youve structured your site. I’m making an attempt to run my very own weblog however I think its too normal and I must give attention to quite a lot of smaller topics. Being all things to all people just isn’t all that its cracked up to be

  4. An attention-grabbing discussion is value comment. I believe that it’s best to write more on this subject, it won’t be a taboo topic but typically persons are not sufficient to talk on such topics. To the next. Cheers

  5. karla

    hi
    do you know how to view the source code of a mail in an ipad or iphone?
    It is difficult to know what is going on in my code and why the gmail reader on ipad is messing up with my design. If you know of something let me know please.

  6. This is an attention-grabbing article which gave me a good idea about how to view html source code on iPod. It helps to get learn more about these topics that not a lot of people talk about–simply because they don't know too much about the topic. Cheers!

  7. Thank you so much for this post Love it.

  8. Everyone said that I can't but I did Doggy

    dan

  9. Very useful when need to View HTML Source on Apple devices , thanks alot

  10. ???? ?????????? ???????? ?? ?????? ???????? ?????????? ???????? ???????? ????-????? ??????????????????? ??????, ????? ????????????-???????, ????? ????????????-???????, ?????????? ??????, ???????? ??????????? ? ??? ?????.

    ????????????? ??????? ???? ???? ?????????????? ??????????? ???????, ??????? ???????? ?? ????? ? ??????????? ??? ?? ??????? ? ? ?? ?? ????? ???????? ???????????????? ???????????.

    ?????? ???????????????? ????????????? ?????? ???????????????? ???????? ?????? ? ?????? ????, ????? ?????????? ????????? ??????, ?????? ? ?????? ???????, ?????????? ?????? ? ????????? ???????, ?????????? ?????? ? ???? ????????. ????????????? ????? ????? ??????????? ???? ???????????? ? ? ?????? ?????? ????????????? ???????????? ?????????? ???????????? ?????, ????????? ?????.

    ??????? ????????????? ?????????? ?????????????? ?????????? ???????? ?? ???????????, ???????? ??????? ? ????????????, ? ??? ??????????? ???????? ??????????? ?????????? ?????? ????????? ????.

    ???? ????????????? ????????????? ???????? ???????? ??????????? ???????? ????? ???????

    ???????? ?? ???????????? ??? ??????? ??? ? ????????????????? ????????.

    ?????????????? ? ?????????????? – ??????? ???????? ??????? ?? ???????????? ?????????

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.