脚本验证错误

发布于 2024-08-29 00:14:19 字数 579 浏览 3 评论 0原文

我的 html 标记中有一个脚本

<script type="text/javascript">
 function setTaxDisplay(display)
 {
  window.location.href += (window.location.href.indexOf('?') > -1 ? '&' : '?') + 'taxInclude=' + display;
 }
</script>

当传递到 validation 它返回那里的&符号无效,但它对页面的功能绝对至关重要,有什么办法我可以让验证器忽略这个吗?我不需要验证页面,我根本不是 JS 专家,我不确定是否可以用 &amp; 替换它。

谢谢。

there is a script in my html tag

<script type="text/javascript">
 function setTaxDisplay(display)
 {
  window.location.href += (window.location.href.indexOf('?') > -1 ? '&' : '?') + 'taxInclude=' + display;
 }
</script>

When passed to validation It returns that the ampersand there isn't valid, but it's absolutely vital to the function of the page, is there a way I can make the validator ignore this? I don't need to validate the page, I'm no JS expert at all I'm not sure if I can replace it with &.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒中人 2024-09-05 00:14:19

您可能正在编写 XHTML 并将其作为 text/html 提供。欢迎体验假装一种标记语言实际上是另一种标记语言的乐趣。

您可以使用注释掉的 CDATA 标记来包装脚本,但您应该将其移动到外部文件。

请参阅http://www.w3.org/TR/xhtml-media- types/#C_4 了解详细信息和示例。

或者,只需编写 HTML。 XHTML 不会给大多数作者带来好处(并且由于您的问题在于验证而不是您正在使用的任何工具,因此您可能不是从使用 XHTML 中受益的作者之一)

You are probably writing XHTML and serving it as text/html. Welcome to the joys of pretending one markup language is really another one.

You can wrap the script with commented out CDATA markers, but you should move it to an external file.

See http://www.w3.org/TR/xhtml-media-types/#C_4 for details and examples.

Alternatively — just write HTML. XHTML doesn't give benefits to most authors (and since your problem is with validation rather then with any of the tools you are using, you probably aren't one of the authors who does benefit from using XHTML)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文