撇号替换输入字段中脚本标记中的引号
我以以下形式输入:
<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,并且已经尝试使用几个模板标签,但没有帮助。
我也尝试过 '
,但是当它包含在属性值中时它不会被转换,所以这也没有帮助。
这看起来像是 HTML 101 的事情之一,但它确实非常烦人。 关于如何解决这个问题有什么想法吗?
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.
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.
I'm using Django, and have already tried using a couple template tags, but it hasn't helped.
I also tried '
, but it isn't converted when it's included within the property value, so that doesn't help either.
This seems like one of those HTML 101 things, but it's really very annoying. Any ideas about how I could fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
Try: