When learning the front-end, friends must be confused about how to introduce external JS files into HTML. The following editor will teach you how to introduce external JS files into HTML.
When an external JS file is introduced, code cannot be inserted between <script></script>. The inserted code will not be executed, only the imported external file will be executed.
attack.html Code:
##
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>系好安全带,准备启航</title> <!--引入外部文件的方式--> <script type="text/javascript" src="attack.js"></script> </head> <body> <form> <input type="button" value="开始游戏" onclick="attackEnemy()"/> </form> </body> </html>
attack.js Code
function attackEnemy() { document.write("land on"); alert("ready go"); }
HTML Tutorial"
The above is the detailed content of Teach you step by step how to introduce external JS files into HTML. For more information, please follow other related articles on the PHP Chinese website!