07-08-2002, 07:34 PM
I have noticed that when I place a string with quotes within another quote, browser gets confused, For example:
var test='This is a test for another "<b>Test</b>" from another "<a>world</a> and another time';
When I use the test variable in the JS, string doesn't appear in the browser. If I use a simple variable w/ no quotes or tags inside, string appears fine.
I'm using IE 6.0.26
07-08-2002, 07:42 PM
If the string starts with a double quote (") you can use single quotes inside the string,and you have to escape the double quotes.
var test="This is a test for another \"<b>Test</b>\" from another \"<a>world</a> and another time";
07-08-2002, 08:25 PM
Can't I use double quotes within double quotes with escape character?
07-08-2002, 09:53 PM
I would suggest that if you use special characters, instead of using the character itself, it would be better to use the codes for them. For eg the double quote(") has a code "
Codes for other characters are also available.
07-08-2002, 10:14 PM
Can you please explain in an example what you mean by code?
07-08-2002, 10:58 PM
The code of a character is an ampersand (&) followed by its code, followed by a semicolon ( ; ). For instance to get the copyright symbol, you enter:
& + copy + ;
You'd write that all together without the plus signs, its just that this forum accepts the code and changes them so you can't see the code.
Which results in ©.
The code for the quotes he's referring to is ampersand, followed by the word "quot" and the semicolon. Just insert that and it will produce a quote that is automatically escaped in HTML. See:
"I used the code for quotes!"
07-09-2002, 11:57 PM
Where can I get the listing of these codes? Is there a webpage?
07-10-2002, 12:03 AM
Their actual name is "character entities".
I don't get this thread: your original question was a perfectly good one and, yes, you can escape (literal) quotes within other (delimeter) quotes easily, Bosko's original answer.