Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Old 10-08-2006, 02:19 PM Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
I want to make tutorials and how tos for HTML and CSS but I can't figure out how to display the code. I have tried the following tags:

Code:
<pre>
<textarea>
<code>
None of them work, the code that I am trying to display is still being rendered. What is wrong all of those tags should work.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-08-2006, 03:33 PM Re: Display code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you have to do the opposite of this. http://www.webmaster-talk.com/asp-fo...sp-decode.html
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-08-2006, 05:43 PM Re: Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
That, is not what I am talking about. I want to be able to display code, so readers see the code like you can see this

Code:
<a href="text.html">test</a>

<h1>Blah</h1>
I want my readers to see the actually html code. But I can't figure out how.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
Old 10-08-2006, 05:48 PM Re: Display code
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
You can use the <code></code> tag. You may also need to use &lt; and &gt; for the angle brackets. You may also find using <pre></pre> helpful to keep your formatting.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 10-08-2006, 05:57 PM Re: Display code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by lunchbox170
That, is not what I am talking about
Actually it is, which is why I said you need to do the opposite

The other thread is asking how to change the < and > back from &lt; & &gt;


so <h1>Blah</h1> is coded as &lt;h1&gt;Blah&lt;/h1&gt;
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-08-2006, 06:30 PM Re: Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
Oh, you are right, that does work. sorry about that. So there is no easier way, it is a pain to type that.

Thanks
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
Old 10-08-2006, 06:59 PM Re: Display code
beta's Avatar
Extreme Talker

Posts: 169
Trades: 0
sure there is... using <code></code> and <pre></pre> as said...
beta is offline
Reply With Quote
View Public Profile
 
Old 10-08-2006, 08:23 PM Re: Display code
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Why do you want to make yet another html 'how to' site ? There are thousands of them out there already !
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 10-08-2006, 08:23 PM Re: Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
As said, Tried it did not work, it should work, but it doesn't.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
Old 10-12-2006, 02:55 AM Re: Display code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
=lunchbox170]So there is no easier way, it is a pain to type that.
Yep there is.
You code a server side function to parse the sections of source code when you need to do the replace.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-12-2006, 07:45 PM Re: Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
That's not easier
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
Old 10-13-2006, 09:53 AM Re: Display code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
it's definitely simpler, write one function, use it wherever it's required.

This one is in ASP VbScript
Code:
function toCode(strItem)
	dim i
'Change code delimiters to HTML entities
	strItem = Replace(strItem,"<","&lt;")
	strItem = Replace(strItem,">","&gt;")
	strItem = Replace(strItem,"%","%")
	strItem = replace(strItem,chr(34),"&quot;")
toCode = strItem	
end function
Use would be
Code:
 response.write tocode("<h1>Blah</h1>")
PHP would be
PHP Code:
function toCode($strItem) {
           
$html = array("<",">",chr(34));
           
$entities = array("&lt;","&gt;","&quot;");
           
$strItem str_replace($html$entities$strItem);
return 
$strItem;

Use would be
PHP Code:
echo toCode('<h1>Blah</h1>'); 
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-13-2006, 10:34 PM Re: Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
no, that really isn't eaier. You have to remember not everyone knows every thing you do.

What I want to know is why code and pre tag don't work?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
Old 10-14-2006, 04:19 AM Re: Display code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
What I want to know is why code and pre tag don't work
It's really quite simple.
HTML is a markup language NOT a scripting language.

That is to say it can only change the way the text will look on the page not how the text is sent to the user agent.

Quote:
You have to remember not everyone knows every thing you do
Yep, which is why I am pointing you to ways you can achieve what you want because HTML alone cannot.

Here is a javascript function to convert the < & > inside a <pre> element to the HTML entities.

Code:
<script type="text/javascript">
function toCode() {
	html = new Array(/</g,/>/g); 
	entities = new Array('&lt;','&gt;'); 
var codeSect = document.getElementsByTagName('pre');
for (var i=0;i<codeSect.length;i++) {
	for (var j=0;j<html.length;j++) {
		codeSect[i].innerHTML = codeSect[i].innerHTML.replace(html[j],entities[j]);
	}

}

}
</script>
Put the function code inside the <head> or in a linked .js file and use <body onLoad="toCode()"> in the document to run the code.
Bear in mind that some UAs do not execute javascript so will see the formatted element rather than the underlying code.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-14-2006, 11:21 AM Re: Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
That didn't work...

It is weird pre and code tag should work, also your thing should have worked, why don't they.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
Old 10-14-2006, 02:02 PM Re: Display code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
why don't they.
No idea, do we get a URL to look at?


removed server is now down
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 08-01-2010 at 05:17 PM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-14-2006, 05:42 PM Re: Display code
lunchbox170's Avatar
Extreme Talker

Posts: 151
Name: Ben
Trades: 0
http://www.thelnews.com

I don't have any code to display right now, and I got rid of the Javascript.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
lunchbox170 is offline
Reply With Quote
View Public Profile
 
Old 10-17-2006, 11:29 PM Re: Display code
bmcoll3278's Avatar
Super Talker

Posts: 118
Name: Brian Collins
Trades: 0
Here is a html solution that may work for you.

I made a test page and uploaded it to my server and it worked

<form NAME="display code">

<DIV align="center">
<input type=button value="Highlight Your Code" onClick="javascript:this.form.txt.focus();this.for m.txt.select();">
</DIV>


<///-----------------------------------------------------begin code display------------------------------------->
<///---------- every thing between these textarea tags will display as code--------------------------------->



<textarea NAME="txt" ROWS=10 COLS=70 WRAP=VIRTUAL>





<HEAD>

Some html stuff

</HEAD>

<BODY>

<font size="5"> this should do the trick for you</font>
<br><p></p>
any othe html stuff you may need
<p><center>

I think this should work
</center><p><p></p>
</form>




</textarea>
</form>
<///---------------------------------end code display------------------------------------------------->
bmcoll3278 is offline
Reply With Quote
View Public Profile Visit bmcoll3278's homepage!
 
Old 10-17-2006, 11:34 PM Re: Display code
bmcoll3278's Avatar
Super Talker

Posts: 118
Name: Brian Collins
Trades: 0
here is the test page I made feel free to look at the code. I hope this helps.
http://www.bayscapades2.com/itworks.html
bmcoll3278 is offline
Reply With Quote
View Public Profile Visit bmcoll3278's homepage!
 
Old 10-18-2006, 02:23 AM Re: Display code
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
You can display the data within a textarea if you assign the value to a variable and echo the variable out in the textarea...

Or just use <xmp>.....

HTML Code:
<xmp><b>Everything will just show out as norma.. code wise.l</b></xmp>
feraira is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Display code

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.64403 seconds with 12 queries