以下是有效的 javascript 吗?该变量是否可用于外部调用的脚本?
<script src="//blah">
var something = "";
</script>
背景:我已经看到这个用于自动生成的分析代码(不是谷歌),这真的让我很烦所以想知道我是否可以修复这个或者这个变量是否会以某种方式被外部引用的脚本使用。
最佳答案
读这个,http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.1
The script may be defined within the contents of the SCRIPT element or in an external file. If the src attribute is not set, user agents must interpret the contents of the element as the script. If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI. Note that the charset attribute refers to the character encoding of the script designated by the src attribute; it does not concern the content of the SCRIPT element.
关于javascript - 带有 src 的脚本标签和脚本标签之间的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19509323/