Results 1 to 8 of 8

Thread: viewing source

  1. #1
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default viewing source

    ok I know that there is probally one of these out there just yet to find one. I need a website to go to where you can type in the webaddress and view the source, because I sometimes look at the source to learn about how people do different things at home and school. Unfortnatly at school they have deleted notepad or something on all computers. So does anyone know anysites or a PHP script to do this myself hmmm.

  2. #2
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    well stupid me. Why can't I just use the w3c validator. It has the ability to show the source but I would also like to know of a PHP script also.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Just paste this into the address bar and hit enter:

    Code:
    javascript:void(document.write('<pre>'+document.getElementsByTagName('html')[0].innerHTML.replace(/</g, '[*')+'<\/pre>'))
    You will see the code for the page except that all:

    <

    symbols will be replaced by:

    [*

    This will allow you to see the code, without this or some other type of replacement, it would simply reproduce the page itself.

    To get back to the page itself, use the browser's back button.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This would be even better, as it will replace with the &lt; entity:

    Code:
    javascript:void(document.write('<pre>'+document.getElementsByTagName('html')[0].innerHTML.replace(/</g, '&lt;')+'<\/pre>'))
    That way the code will look about right. Many things will be stripped though, with either method. Such as the DOCTYPE and all quotation and other marks not required by the browser's parsing engine to interpret the code.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    hmm ok well good idea. I have been messing around with a script that you can view here http://benslayton.awardspace.com/source.php. But that shows the source for the index.php file in that folder.

    here is the code if you want to play with it:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>View Source</title>
    <style type="text/css">

        body {
        
            background-color: #111111;
            font-family: Courier New, Courier, mono;
            font-size: 11px;
            color: #66CCFF;
        
        }
        
        span {
        
            color: #FFFFFF;
        
        }
        
        .linenumber {

            color: #FF9900;    
        
        }
        
        em {
        
            color: #666666;
        
        }
        
        h3 {
        
            font-family: Tahoma, Trebuchet MS, Arial;
            text-decoration: none;
        
        }
        
        .codelink {
        
            font-family: Tahoma, Trebuchet MS, Arial;
            text-decoration: none;
            font-size: 10px;
            color: #EEEEEE;
        
        }
        
        .codelink:hover {
        
            font-family: Tahoma, Trebuchet MS, Arial;
            text-decoration: underline;
            font-size: 10px;
            color: #66CCFF;
        
        }

    </style>
    </head>

    <body>
    <?php

        $url 
    "http://" $_SERVER'HTTP_HOST' ] . "/" urldecode$_GET"u" ] );
        
    $lines file$url );

    ?>
    <?php

        
    foreach( $lines as $line_num => $line ) {

        
    $line htmlspecialchars$line );
        
    $line str_replace"&lt;"'<span>&lt;'$line );
        
    $line str_replace"&gt;"'&gt;</span>'$line );
        
    $line str_replace"&lt;!--"'<em>&lt;!--'$line );
        
    $line str_replace"--&gt;"'--&gt;</em>'$line );

        echo 
    "" $line "<br/>\n";

        }

    ?>
    </body>
    </html>

    Edit: oh yeah I would like a form asking for the url and you type in the address and you click sumbit and you can see it.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Or, you could use &lt; instead of [*.

    /EDIT: Gah, router's so slow that by the time it'd finished POSTing, there were a whole two replies :-\ Someone'll probably have commented on that before this edit gets sent, too.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    you know what like always I just fixed my own problem. I guess its just a matter of time.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It's a little tricky but, you could make it a bookmark.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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