View Full Version : View Source bookmarklet
beetle
08-21-2002, 12:43 AM
Here's a bookmarklet I made for viewing page source. Lets you see how the browser sees the HTML. Tested on IE6javascript:var h = document.documentElement.outerHTML; var nTitle = window.location.href; h=h.replace(/</g, '<'); var srcWin; srcWin = window.open('','srcWin',''); with (srcWin.document) { writeln('<html><head><title>Source Code for '+nTitle+'</title></head><body>'); writeln('<pre>'); writeln(h); writeln('</pre>'); writeln('</body></html>'); close(); }
This works in Mozilla:
javascript:window.open('about:blank').document.write('<pre>' + unescape((new XMLSerializer()).serializeToString(document).replace(/</g, '<')) + '</pre>')
And this is a shorter version for IE:
javascript:window.open('about:blank').document.write('<pre>' + document.documentElement.outerHTML.replace(/</g, '<') + '</pre>')
beetle
08-21-2002, 01:11 AM
Cool. I know someone could make it shorter...course that version doesn't include the TITLE...:p
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.