wannabe_god Posted September 3, 2006 Share Posted September 3, 2006 I'd like a way to ignore a quote, or something like that, so that i can write a double quote in a string. Something like document_write('''<td onmouseover="alert('hi')">hi</td>'''); why are there no triple quotes Link to comment Share on other sites More sharing options...
Jack McKalling Posted September 3, 2006 Share Posted September 3, 2006 You have to escape the quotes of the same type the string is in, by the backslash. document_write('<td onmouseover="alert(\'hi\')">hi</td>');But there are lots of other similar valid ways, you can use HTML entities inside the alert() function ("), you can use double quotes for the string and escape the inner double quotes, instead of the singles, etc. Possibly even more qays. So this is only an example :)This is how I would do it when I use javascript:document_write("<td onmouseover='alert(\"hi\")'>hi</td>");Because I want to use the same quot syntax I use with PHP, and then I am forced to use double quotes for the string, to be able to escape signs in it (when the string is single quoted in php, it doesn't parse special characters) Link to comment Share on other sites More sharing options...
wannabe_god Posted September 3, 2006 Author Share Posted September 3, 2006 Thank you! :)I knew it was something like that, i just tested it with / ... Link to comment Share on other sites More sharing options...
Jack McKalling Posted September 3, 2006 Share Posted September 3, 2006 Lol. No only a backslash, it is always a backslash that says "the folowing sign is a literal character", and much other things in other situations too. The slash is only used to close html elements :)Glad to help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now