2012-11-25

View rendered source bookmarklet

I haven't made a bookmarklet from scratch in a long while, but after looking at this codepen I wrote a while ago to demonstrate copying one javascript document into another, it occurred to me that it could easily become a modern "view rendered source" bookmarklet, that might even work on iOS devices and the like, where a view source feature is sorely missing.

Here is the result: view rendered source

On clicking it, you get a "view source" iframe with the source of the current document, in whichever state it was when you clicked the button, and when you click (or tap) that it goes away again.

I have yet to try it on an iDevice myself, but I have high hopes. To my surprise, manually entered bookmarklets like this one refuse to run in a modern Safari, though smaller ones that load their js payload over the wire instead seem to work, so I might make a gist of the code too, if that is what it takes.

Enjoy!