Ralpharama Archive. The archive is almost 20 years old, this website is no longer maintained.

Home | New Writing | Old Writing | Cooking | Technical | Wine Making | Cocktails

Output html with Javascript in VBScript/ASP

Hits 4577 | Created 2007-07-05 | Modified 2007-07-05

If you want to output a large amount of HTML, say the body of a news story, but don't want it to be read by spiders and bots for some reason, you could use this trick to render it, client-side only, in Javascript:

Response.Write "<script type=""text/javascript"">"&vbCr
Response.Write "<!--"&vbCr
StoryBody = Replace(StoryBody, "'", "\'")
StoryBody = Replace(StoryBody, Chr(10), "")
StoryBody = Replace(StoryBody, Chr(13), "';"&vbCr&"str+='")
Response.Write "var str='"&StoryBody&"';"&vbCr
Response.Write "document.write(str);"&vbCr
Response.Write "-->"&vbCr
Response.Write "</script>"&vbCr

Make a Comment


Antispam Code (always a number)

Enter Code Above

Note: All HTML will be removed except for bold and italics. Links will not display. Line breaks are added automatically. Use <pre>...</pre> for code.


This item has the following tags:
tech javascipt asp vbscript html

Useful? Donate for hosting costs

All content copyright (c) Ralpharama