如何使 Google+ JavaScript 标签通过 W3C 验证

How to make Google+ JavaScript tag pass W3C validiation

我的网站上有 Google+ 按钮。它工作正常,但 W3C 验证程序显示错误:

The text content of element script was not in the required format: Expected space, tab, newline, or slash but found < instead.

代码如下:

<script src="https://apis.google.com/js/platform.js" async defer>lang:"pl";</script>

我该如何解决这个问题?

W3C 验证器抱怨 <script src...> 标签的内容。根据 these specs,具有 src 属性的脚本标签只能包含空格 and/or JavaScript 注释。

您可以使用 the following syntax 代替:

<script>
    window.___gcfg = { lang: "pl" };
</script>
<script src="https://apis.google.com/js/platform.js" async defer></script>