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

Discussion in 'Javascript' started by Sandip Chitale, Nov 20, 2003.

  1. // Bookmarklet by Sandip Chitale ()
    // 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();
     
    Sandip Chitale, Nov 20, 2003
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cloud Burst
    Replies:
    11
    Views:
    1,553
  2. Stu
    Replies:
    2
    Views:
    917
    Rob McAninch
    Apr 6, 2004
  3. André
    Replies:
    3
    Views:
    1,977
  4. Valli
    Replies:
    1
    Views:
    1,254
    Mike Placentra II
    Oct 3, 2007
  5. bdb112
    Replies:
    45
    Views:
    1,941
    jazbees
    Apr 29, 2009
  6. Berry B

    Including script in HTML

    Berry B, Feb 16, 2004, in forum: Javascript
    Replies:
    3
    Views:
    160
  7. dave
    Replies:
    1
    Views:
    172
    kaeli
    Apr 13, 2004
  8. Replies:
    2
    Views:
    289
    Jeremy
    Nov 21, 2006
Loading...