在html中引入外部js文件,并调用js文件中的带参函数
1 项目结构

2 编写a.js、test.html
//a.js
function abc(str){
alert(str);
}//test.html
<html>
<head>
<script type="text/javascript" src="a.js"></script>
<script type="text/javascript">
window.onload = function(){
var fun = abc; //引用abc函数
fun(123);
};
</script>
</head>
<body>
</body>
</html>3 测试结果

版权声明:本文为congju原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。