如何在javascript函数参数中显示特殊字符 [英] how to display the special characters inside javascript function arguments

查看:43
本文介绍了如何在javascript函数参数中显示特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是需要传递到javascript函数中的字符串,因为我不想执行替换操作,我需要显示原始主题字符串,而无需对String值进行任何修改.

Below is the string that needs to be passed into the javascript function as i do not want to do the replace , i need to display the original subject string without any modification in the String value.

 String subject="The apostrophe ( ’ or ' ) < is a punctuation mark,";
 <td style="border: none"><a>href="javascript:showPopUpMsg('<%=subject%>')</a></td>

能否请我建议如何解析这些特殊字符.

can you please suggest me how to parse these special characters.

推荐答案

我不会编写代码来转义单个字符,而是使用已经可以完成此工作的现有库-一次一劳永逸.您将找到有关必要转义符(全部为 )的信息,以及在

I wouldn't write code to escape individual characters, but rather go with an existing library that already does the job - once and for all. You'll find information about the necessary escapes (all of them) as well as links to libraries on the OWASP page

这篇关于如何在javascript函数参数中显示特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆