Home > php教程 > PHP开发 > body text

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

高洛峰
Release: 2016-12-08 13:26:49
Original
3003 people have browsed it

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>
Copy after login

3 Test results

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



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!