Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I print out script tags and javascript?

Status
Not open for further replies.

dcnguyen

Technical User
Mar 22, 2005
54
US
OK, I'm creating a page that, upon some input and a button click, prints out some Javascript (including script tags) for people with even less JS knowledge than myself to copy and paste...

So basic question..How do I print this out on the webpage using a, for example, document.getElementById("textplace").innerHTML = "txt here", call? Without the script tags and code being processed, I mean.
 
You would have to escape your quotes and less/greater than signs. So this:
Code:
<script type="text/javascript">
document.getElementById("textplace").innerHTML = "txt here";
</script>

would become this:

Code:
&lt;script type=&quot;text/javascript&quot;&gt;
document.getElementById(&quot;textplace&quot;).innerHTML = &quot;txt here&quot;;
&lt;/script&gt;


-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top