第1个回答 2016-11-14
------解决方案--------------------
sample.js 中
var type = 1;
HTML中
function xxx(){
var type2 = type;
}
------解决方案--------------------
<script src="sample.js"></script>
假如:sample.js里面有个变量var content = "这是全局变量";
Html的其他位置script块里都可以用
<body>
<script>
alert(content);
</script>
</body>