Home >Web Front-end >HTML Tutorial >Teach you step by step how to introduce external JS files into HTML
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 3f1c4e4b6b16bbbd69b2ee476dc4f83a2cacc6d41bbb37262a98f745aa00fbf0. 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"); }Thank you everyone for reading, I hope you will benefit a lot. This article is reproduced from: https://blog.csdn.net/u012871987/article/details/72638373Recommended tutorial: "
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!