Introduce external js files into html and call parameterized functions in js files
1 Project structure
2 Write 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 Test results
