【问题标题】:Apostrophes replacing quotation marks in script tag in input field撇号替换输入字段中脚本标记中的引号
【发布时间】:2010-09-30 15:05:37
【问题描述】:

我在一个表单中有这个输入:

<input type="text" value="<script src='/js/script.js' type='text/javascript'></script>"  name="embed"/>

一般来说引号必须是双引号,所以我在 value 属性中放了单引号。

但是,当我这样做时,结果是:

<script src=’/js/script.js’ type=’text/javascript’></script>

请注意,这些是撇号,而不是单引号!在 HTML 方面有很大的不同。

我正在使用 Django,并且已经尝试使用几个模板标签,但没有帮助。

我也试过&amp;#39,但是当它包含在属性值中时它不会被转换,所以这也无济于事。

这看起来像是 HTML 101 中的一种,但它真的很烦人。关于如何解决此问题的任何想法?

【问题讨论】:

    标签: html django scripting quotes apostrophe


    【解决方案1】:

    试试:

    <input type="text" value="&lt;script src=&quot;/js/script.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;" name="embed"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-18
      • 1970-01-01
      • 2013-03-09
      • 1970-01-01
      • 2018-11-16
      • 2019-10-29
      相关资源
      最近更新 更多