?
Solved

HTML views exact source - no parsing

Posted on 2003-03-03
9
Medium Priority
?
182 Views
Last Modified: 2010-04-09
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
0
Comment
Question by:joshence
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 17

Accepted Solution

by:
dorward earned 180 total points
ID: 8060429
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
 
LVL 33

Expert Comment

by:knightEknight
ID: 8060431
<a href="view-source:http://this.server.com/thispage.htm">view source</a>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 8060450
and more generally:

<a href="#" onclick="location='view-source:'+this.href;return false;">view source</a>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:webwoman
ID: 8064934
What's wrong with just right clicking and choosing VIEW SOURCE? You're the one doing the presentation, right?
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 8065426
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
 
LVL 2

Expert Comment

by:memerot
ID: 8065445
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
 
LVL 1

Expert Comment

by:tripst3r
ID: 8065516
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
 

Author Comment

by:joshence
ID: 8144891
the *.phps is exactly what I wanted.  AWESOME.  

Thank you so much
0
 

Author Comment

by:joshence
ID: 8144983
sorry I accepted this before and forgot to give you a grade.  Thanks again dorward
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question