Tutorial :javascript error apostrophe


i have in my jsp a js function to open a popup, in this function I pass as parameter, this parameter is a message like this

L'appareil est en panne

but when i load my page i have a javascript. how i can i do before i load my page to do this*

L''appareil est en panne


You can escape quotes inside strings using backslashes:

alert('L\'appareil est en panne\'');  

there's a Java class that seems to do the job: StringEscapeUtils.escapeJavaScript(). Boy, you Java guys have a class for everything!


Altough your question is not very clear. But you can use escape character \' to resolve such problems.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »