HTML views exact source - no parsing

hey - I am going to do a presentation soon about some code that i've been writing.  It would be really nice to have a popup that just displays the code (I know it can open a wordpad thing using javascript but I want this in an actual webbrowser).  In other words I want to have this done automaticly I DO NOT WANT TO go through all my code change it from this:
<head>
<title>TITLE</title>
</head>

to this: (sorry about the spaces...needed for you to see what I want)
& l t ; head & g t ;
& l t ;title & g t ;TITLE& l t ;/title & g t ;
& l t ;/HEAD & g t ;

ALSO - I would like to do the same with PHP code.  Thanks in advance
joshenceAsked:
Who is Participating?
 
dorwardConnect With a Mentor Commented:
Put the code in a .txt file, most servers are configured to send files with a .txt extension as text/plain. Unfortunatly MSIE thinks it knows better then you and will treat it as HTML anyway, but you can get around that by using Mozilla, Opera or Netscape.

Or - use search and replace to change & to &amp; then < and > to &lt; and &gt;

As for PHP - stick it in a .phps file. Most servers that can cope with PHP will syntax highlight it for you. Come to think of it, that will probably work for your HTML too.
0
 
knightEknightCommented:
<a href="view-source:http://this.server.com/thispage.htm">view source</a>
0
 
knightEknightCommented:
and more generally:

<a href="#" onclick="location='view-source:'+this.href;return false;">view source</a>
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
webwomanCommented:
What's wrong with just right clicking and choosing VIEW SOURCE? You're the one doing the presentation, right?
0
 
knightEknightCommented:
true.  alternatively, you can view the source of multiple sites / pages from one page like this:

<a href="#" onclick="location='view-source:'+this.href;return false;">view THIS source</a> <br />
<a href="http://www.experts-exchagne.com/" onclick="location='view-source:'+this.href;return false;">view EE source</a> <br />
<a href="http://www.foxnews.com/" onclick="location='view-source:'+this.href;return false;">view FOX source</a> <br />
0
 
memerotCommented:
This is better than View Source.  The easy answer, and an invaluable resource, is the View Partial Source tool for IE.  Microsoft says it's not supported for IE6 for some reason, but it works fine.  You can find it at: http://www.microsoft.com/windows/ie/previous/webaccess/webdevaccess.asp   Their description: "...for those who are tired of scrolling through hundreds of lines of HTML to find that one section of code that does what you want, search no more! Simply highlight the area of Web page that you want to see the source for, right click on it and select 'View Partial Source.' It's that simple! "

It shows you the source as IE reads it, so your quotes and the order of attributes and stuff like that are not preserved.  But you can download it in 30 seconds and use it for your presentation.  The only caveat is that you need to close the window that pops up after each view, or else the script driving the thing breaks.

This tool also lets you see not just the html - BUT ALSO the value of hidden form fields as they're set by script.  So you look at the initial page, view partial source, then do some action and view partial source again and you can see if your form fields are being set to the right values.  I recommend this tool to EVERY web developer out there, it's great.

It only shows HTML though, nothing server side (like PHP).  There you're out of luck.

0
 
tripst3rCommented:
For server-side code, you're going to have to either open the file using PHP methods, write it to a buffer, RegEx through it to change what you want to change, and print out the result, OR open the file using PHP methods, write the file to a text file, and open the text file.

With a little elbow grease, you could probably write a function that would iterate over a directory and write all of the files to text files. You could call that function from an admin page just before your presentation (or any future presentation) and have the TXT files at your disposal.
0
 
joshenceAuthor Commented:
the *.phps is exactly what I wanted.  AWESOME.  

Thank you so much
0
 
joshenceAuthor Commented:
sorry I accepted this before and forgot to give you a grade.  Thanks again dorward
0
All Courses

From novice to tech pro — start learning today.