开发者

javascript error apostrophe

开发者 https://www.devze.com 2023-01-07 19:12 出处:网络
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

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 pan开发者_JAVA百科ne


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消