English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Method for including external js files in html and calling parameterized functions

Introduce external js files in 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; //reference abc function
	fun(123);
  };
 </script>
</head>
<body>
</body>
</html>

3 Test Results

This is the full content brought to you by the editor on how to introduce external js files in html and call parameterized functions, please support and cheer for the tutorial~

You may also like