Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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

share|improve this question
    
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 Feb 25 '12 at 5:57

1 Answer 1

up vote 3 down vote accepted

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)();
share|improve this answer
    
That works great, thank you! Is there any way I can get the text size to be a bit smaller? –  timothymh Feb 25 '12 at 0:39
    
Sorry, I didn't write it and may javascript currently sucks. –  afragen Feb 25 '12 at 1:50
    
Ah, OK then. I'll cope. –  timothymh Feb 25 '12 at 2:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.