View Full Version : Response.Write()

03-13-2004, 03:18 AM
Hi. I just wrote my first asp scripts and had a question.

Got an asp script that reads another web site's xml file, genertaing javascript array information. Such as:

dte[0] = (2004, 3-1, 14) ; mes[0] = '<a href="http://tmp.htm">title</a>'

The Response.Write() seems to take a '<a href="http:\/\/tmp.htm">title<\/a>' and convert it to '<a href="http://tmp.htm">title</a>'. Just like document.write(). The problem is that I need to do a document.write(mes[0]) in my html code.

Question. Is there a way for the asp script to generate:

dte[0] = (2004, 3-1, 14) ; mes[0] = '<a href="http:\/\/tmp.htm">title<\/a>'

03-13-2004, 11:55 AM
AFAIK document.write(mes[0]) will work, since escape codes are only necessary when you hard-code the string. Have you tried?


03-13-2004, 08:50 PM
Oh it does work. I'm just worried it won't work all the time or for all browsers.

Actually, the mes[0] ends up in a document.all['id'].innerHTML=mes[0]. You said converting '/' to '\/' is only needed for hardcoding your string. Could you explain?

03-14-2004, 09:42 AM
Well, basically, stuff like that (escape sequences in strings) is only important when the software (the ASP engine in this case) is parsing the code, once it is stored in a variable there is no trace of the escape sequence, and the appropiate character (it's ASCII code) is already stored in the memory that relates to that variable.
There is no reason at all why it shouldn't work on any browser.