Hi I have a problem with a javascript string
var foo = \"<a href="javascript(foo('a','b'))">test</a>\"
This sentence gives me an error
I could have escaped inner " but I am not allowed to change <a href="javascript(foo('a','b'))">test</a>
this part
Is there any way to handle this condition?
Thanks, Sourabh
Several years later, this is now possible with String.raw()
let foo = String.raw`<a href="javascript(foo('a','b'))">test</a>`
No, you need to escape the string somehow.
var foo = "<a href=\"javascript(foo('a','b'))\">test</a>";
or
var foo = '<a href="javascript(foo(\'a\',\'b\'))">test</a>';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With