Solved

display html code

Posted on 2003-10-23
10
602 Views
Last Modified: 2013-12-16
hello,
i maintain a website that provides counters.  To install the counters i  have a page that gives them the html.  here is the page:

http://myfreecounter.net/gethtml.php?id=1

but when users copy the html and paste it into ms Frontpage or another html editor, it usually changes to this:

<script src="http://www.myfreecounter.net/script.php?id=1" language="Javascript1.2"></script>
<noscript><img src="http://www.myfreecounter.net/noscript.php?id=1"></noscript>

it does that even if they copy it in HTML mode.  I thought about using a textarea to display the html to paste, but i wouldnt think that would look polished, i need something that will look nice, but still copy correctly.

thank you,
Matt
0
Comment
Question by:mattjp88
10 Comments
 
LVL 29

Expert Comment

by:coreybryant
ID: 9610477
I think that you would need to either use the text area - or tell the FP users to copy & paste it into notepad before pasting it into HTML.  

-Corey
0
 
LVL 3

Expert Comment

by:superslamwich
ID: 9610716
You can try using this for a better look for the textarea:

<textarea style='overflow:hidden;background-color:#000000;color:#FFFFFF;' readonly rows='10' cols='50'><script src="http://www.myfreecounter.net/script.php?id=1" language="Javascript1.2"></script>
<noscript><img src="http://www.myfreecounter.net/noscript.php?id=1"></noscript></textarea>

You can change the colors to whatever you want

{Slam}
0
 
LVL 2

Expert Comment

by:HeadAcheMike
ID: 9611037
agreed but you should code it like this

<textarea style='overflow:hidden;background-color:#000000;color:#FFFFFF;' readonly rows='10' cols='50'>
&lt;script src="http://www.myfreecounter.net/script.php?id=1" language="Javascript1.2"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;img src="http://www.myfreecounter.net/noscript.php?id=1"&gt;&lt;/noscript&gt;
</textarea>

this makes sure the tags inside the text area wont get confused at design time and it displays properly in the browser
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 31

Accepted Solution

by:
seanpowell earned 50 total points
ID: 9611070
Or this:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Copy Code</title>
<style>
<!--
p { font-family: Verdana; font-size: 13px }
-->
</style>
</head>
<body>
<table BORDER=0 CELLPADDING=10 CELLSPACING=0>
  <tr>
    <td BGCOLOR=#cccccc align="center">
    <p><b>Just put this image tag into the BODY of your html document.</b><br>
    Click the Highlight All Button, right click the text, select copy then and paste into your html editor</p></td>
  </tr>
  <tr>
    <td BGCOLOR=#cccccc align="center">
    <form NAME="copy">
    <DIV align="center">
    <input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">
    </DIV>
    <br>
    <textarea style='overflow:hidden;background-color:#ffffff;color:#000000;' name="txt" readonly rows='4' cols='95' WRAP=VIRTUAL>

&lt;script src="http://www.myfreecounter.net/script.php?id=1" language="Javascript1.2"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;img src="http://www.myfreecounter.net/noscript.php?id=1"&gt;&lt;/noscript&gt;

    </textarea>
    </td>
  </tr>
</table>
</form>
</body>
</html>
0
 
LVL 3

Expert Comment

by:superslamwich
ID: 9611310
Hopefully people aren't so lazy they need an auto-select for such a short amount of text :-)

And I believe most browsers do render <tag>'s in textareas as long as they are not </textarea>, although you are right you can't be too careful with all the different browser standards out there.
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9611374
>>Hopefully people aren't so lazy
I agree - but I've had experience with people that don't "correctly" copy all the text - missing an opening or closing bracket, etc. It's just some added security...
0
 
LVL 3

Expert Comment

by:superslamwich
ID: 9611433
I suppose you can never trust too much to the user  ;-)
0
 
LVL 7

Assisted Solution

by:Xxavier
Xxavier earned 50 total points
ID: 9611492
To be honest this is usually done on most pages ias below, there nothing wrong with a text area. Most page developers are familiar with this any anything else I think would confuse.

<html>
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s). The script is yours!!!
<form>
<input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<textarea NAME="txt" ROWS=6 COLS=75 WRAP=VIRTUAL>
<script src="http://www.myfreecounter.net/script.php?id=1" language="Javascript1.2"></script>
<noscript><img src="http://www.myfreecounter.net/noscript.php?id=1"></noscript>
</textarea>
</form>
</html>

0
 
LVL 1

Expert Comment

by:paStiSSet
ID: 9618295
you can also use <blockquote> the code here </blockquote>
0
 
LVL 6

Author Comment

by:mattjp88
ID: 9924385
sorry about the delay on follow up, but your suggestions did exactly what I wanted.

thanks,
Matt
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 27
Insert Button on a table 16 38
Extracting content from meta tag PHP MYHTML DOM 3 21
CSS Style Effect 2 11
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

830 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