Serviceboy 发表于 2012-12-22 21:28:09

用C#动态输出js单引号问题

<div id="cnblogs_post_body">一次在论坛上碰到某人需要动态用C#在后台输出“我要'飞'”的字符串——其中“飞”上带有一对单引号。当时我就这样想……在纯Html中js代码这样写:
<div class="cnblogs_code"><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <title></title>    <script type="text/javascript">       function MyClick() {            alert("OK");            alert('我要\'飞\'');      }    </script></head><body>    <p>      <input id="Button1" type="button" value="button" onclick="MyClick()" />    </p></body></html>
页: [1]
查看完整版本: 用C#动态输出js单引号问题