PDA

View Full Version : display html source in web page?


teksigns
07-18-2004, 03:20 PM
how can i convert a table i made with html so that the source
will be displayed to the user so that they can copy the html
to insert on there site .

i know i can do a manual replace of the ascii codes bu this would take forever .

are there any easy way to do this ?

Loon
07-18-2004, 03:26 PM
print htmlentities($text);

http://php.net/htmlentities

teksigns
07-18-2004, 03:29 PM
so how would i do this
if im not going to use php?

Loon
07-18-2004, 03:37 PM
erm, well i guess you could get away with something like this:

<script type="text/javascript">
<!--
function tagReplace(text)
{
newText = text.replace('<','&lt;');
newText = text.replace('>','&gt;');

document.write(newText);
}
// -->
</script>

Modin
07-19-2004, 12:21 AM
lots of people do this by putting the html you can copy in a textarea box.


<textarea> your html code... </textarea>