javascript - 带有 src 的脚本标签和脚本标签之间的代码

标签 javascript

以下是有效的 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/

相关文章:

javascript - HTML+CSS奇怪的DIV错误

javascript - $window.sessionStorage 用于登录和注销(基于 token );

javascript - Nuxt JS |在哪里/如何设置全局数据

javascript - Watchify 不发出更新事件

javascript - 单击表行时使用 React 门户显示模式组件(?)

javascript - vue 组件中无法包含 Highcharts

javascript - 如何使用 JavaScript 创建网页指导教程?

javascript - 是否可以在从其他服务器下载之前动态压缩文件?

javascript - 如何在 typescript 中注释生成器函数

javascript - Backbone.js目录结构