Show the true html source of a web page (including that generated by script).

S

Sandip Chitale

// Bookmarklet by Sandip Chitale ([email protected])
// Function: Show the true html source of a web page (including that generated by script).
// Usage: 1. Copy these to a file (say - 'c:/bookmarklets/viewfinalsource.js')
// 2. Visit any website
// 3. copy and paste the following line in your address bar starting with the word 'javascript:'
// javascript:void((function() {var
element=document.createElement('script');element.setAttribute('src','c:/bookmarklets/viewfinalsource.js');
document.body.appendChild(element)})())
// 4. Alternatively, create a bookmark (or also a Links toolbar shortcut in case of IE) for it to access the functionality
with a single click.
function viewFinalSource() {
var _console = null;
// open a window the first time we are called, or after an existing
// console window has been closed.
if ((_console == null) || (_console.closed)) {
_console = window.open("","console","width=600,height=300,resizable,scrollbars=yes");
// open a document in the window to display plain text
_console.document.open("text/plain");
}
var gt = /\>/g;
var lt = /\</g;
var el = /\n\s*\n/g;
_console.document.writeln(document.documentElement.innerHTML.replace(gt,">\n").replace(lt,"\n<").replace(el,"\n"));
}
viewFinalSource();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top