撇号替换输入字段中脚本标记中的引号

时间:2020-12-27 22:25:10

I have this input in a form:

我有一个表格的输入:

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

The quotations in general have to be double, so I put single-quotes within the value property.

引用通常必须加倍,因此我将单引号放在value属性中。

However, when I do that, the result is:

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

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

Notice that these are apostrophes, not single quotes! Big difference when it comes to HTML.

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

I'm using Django, and have already tried using a couple template tags, but it hasn't helped.

我正在使用Django,并且已经尝试过使用一些模板标签,但它没有帮助。

I also tried &#39, but it isn't converted when it's included within the property value, so that doesn't help either.

我也尝试了#39,但是当它包含在属性值中时它没有被转换,所以这也无济于事。

This seems like one of those HTML 101 things, but it's really very annoying. Any ideas about how I could fix this?

这似乎是那些HTML 101之一,但它真的很烦人。关于如何解决这个问题的任何想法?

1 个解决方案

#1


Try:

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

#1


Try:

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