c# - 关闭脚本标记和 document.write 在 Visual Studio 中被标记

标签 c# javascript asp.net

环境:Visual Studio 2008 SP1、ASP.NET 和 JavaScript

我正在尝试做一个快速 document.write测试,但只要我添加脚本标签,Visual Studio 编辑器就不喜欢它。具体来说,结束脚本标签?我一进入收盘价就得到那些波浪线 </script>标签

<html><head></head><body>
    <script type='text/javascript'>
      document.write('<html><head><script></script></head><body></body></html>');
    </script>
</body>
</html>

最佳答案

使用:

document.write('<html><head><script><\/script></head><body></body></html>');
Note the `\`, here ------------------^

另一种选择是拆分字符串,这样它就不是一个精确的标签:

document.write('<html><head><script></sc' + 'ript></head><body></body></html>');

这里有一个解释为什么需要它的引用,以及其他选项:

不管怎样,你为什么要将整个文档写入 <body>

关于c# - 关闭脚本标记和 document.write 在 Visual Studio 中被标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16065816/

相关文章:

c# - 如何对某些 DbSet<Class> 的 ICollection<> 属性使用 Skip() 和 Take()

c# - 如何在 VS 2017 中将 csproj 文件更改回旧格式

javascript - <base> 标签破坏了 SVG 标记端渲染

javascript - 使用 d3 javascript 库附加 DOM/SVG 元素会更改变量引用/范围,为什么?

javascript - 在后面的asp.net代码中调用类点击功能

c# - Paypal 立即购买按钮快速结帐

html - contert_placeholder 上的内容与页脚重叠

c# - ConfigurationManager 在不同的系统上寻找不同的文件

javascript - 在jquery中遍历dom?

c# - 我是否使用 C# 中的 foreach 以 FIFO 方式获取 Dictionary 中的元素?