Home >php教程 >PHP开发 >Introduce external js files into html and call methods with parameter functions

Introduce external js files into html and call methods with parameter functions

高洛峰
高洛峰Original
2016-12-08 13:26:493105browse

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

Introduce external js files into html and call methods with parameter functions



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn