Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts

    View Source bookmarklet

    Here's a bookmarklet I made for viewing page source. Lets you see how the browser sees the HTML. Tested on IE6
    Code:
    javascript:var h = document.documentElement.outerHTML; var nTitle = window.location.href; h=h.replace(/</g, '&lt;'); 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(); }

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    This works in Mozilla:

    javascript:window.open('about:blank').document.write('<pre>' + unescape((new XMLSerializer()).serializeToString(document).replace(/</g, '&lt;')) + '</pre>')

    And this is a shorter version for IE:

    javascript:window.open('about:blank').document.write('<pre>' + document.documentElement.outerHTML.replace(/</g, '&lt;') + '</pre>')
    Last edited by jkd; 08-21-2002 at 12:05 AM.

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool. I know someone could make it shorter...course that version doesn't include the TITLE...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •