内部引用
< ! DOCTYPE html >
< html >
< head >
< script type=" text/javascript " >
document.write(" Hello World! ");
< /script >
< /head >
< /html >
外部引用
< ! DOCTYPE html >
< html >
< head >
< script type = " text/javascript " src = " Hello.js " >< /script >
< /head >
< /html >
hello_01.html
< ! DOCTYPE html >
< html >
< head >
< meta charset = "UTF-8" >
< title > 外部脚本的使用 < /title >
< script src = " hello_01.js " >< /script >
< /head >
< /body >
< /h1 id = " helloMessage " > < /h1 >
< /body >
< /html >
hello_01.js
// JavaScript Document
window.onload = writeMessage;
function writeMessage(){
document.getElementById("helloMessage").innerHTML = "Hello, World!";
}
网友评论