2

Is there a way for non-jailbroken iOS to view the source code for a web page? Does Apple's web API allow this?

1
  • There may also be HTML/CSS editors in the App store that will allow you to see the HTML source for any appropriate URL.
    – hotpaw2
    Commented Feb 25, 2012 at 5:57

1 Answer 1

3

Add the following as a bookmark. I call mine View Source. It will open up a new window with the HTML source.

javascript:(function()%7Bvar%20a=window.open(%22about:blank%22).document;a.write(%22%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3ESource%20of%20%22+location.href+'%3C/title%3E%3Cmeta%20name=%22viewport%22%20content=%22width=device-width%22%20/%3E%3C/head%3E%3Cbody%3E%3C/body%3E%3C/html%3E');a.close();var%20b=a.body.appendChild(a.createElement(%22pre%22));b.style.overflow=%22auto%22;b.style.whiteSpace=%22pre-wrap%22;b.appendChild(a.createTextNode(document.documentElement.innerHTML))%7D)();
3
  • That works great, thank you! Is there any way I can get the text size to be a bit smaller?
    – Tuesday
    Commented Feb 25, 2012 at 0:39
  • Sorry, I didn't write it and may javascript currently sucks.
    – afragen
    Commented Feb 25, 2012 at 1:50
  • Ah, OK then. I'll cope.
    – Tuesday
    Commented Feb 25, 2012 at 2:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .