[Javascript] displaying single quotes or double quotes in javascript alert

Rodney Myers rodney at aflyingstart.net
Fri Jul 6 08:50:06 CDT 2001


Laurent is right about the use of the backslash, but the backslash is probably
NOT in the data as stored on the server. What you must then do is to replace the
quotes with backslash+quote mark in the string to be put into the alert.

To do this you need to use additional backslashes so that the backsalsh you want
to insert is taken literally.

 I think server side remedies would be best where you may have the data safely
in variables that can be manipulated rather than writing a string to the HTML
page that needs quote delimiters, but may contain them.

Rodney

"Muchacho, Laurent (TWIi London)" wrote:

> Hi
>
> Your solution it's quite simple write \" or \' backward slash in front of
> the quote or the single quote
>
> Laurent
>
> -----Original Message-----
> From: Russell Scheinberg [mailto:rscheinberg at lrk.com]
> Sent: 06 July 2001 14:27
> To: javascript at LaTech.edu; aspfreeforall at ls.asplists.com
> Subject: [Javascript] displaying single quotes or double quotes in
> javascript alert
>
> I am trying to create some alerts in javascript that make reference to
> variables created with ASP. I can get the data in the variables to display
> just fine, except when they contain single or double quotes, which of course
> causes a problem in the string and a error to occur. I was wondering if
> there is a display code for these characters as there is in visual basic or
> html (&rsquot;,") that I could do a Replace() with and not cause the
> script to choke.
>
> Thanks.
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript

--
Shop at ssistant Add-ons and Developer Workshops
http://www.aflyingstart.net/addons/

Enquiries regarding Shop at ssistant Classic training :
Call 01256 880770

Rodney Myers
Based in Oxford, England
Technical Director, Shop at ssistant eCommerce Solutions






More information about the Javascript mailing list