美文网首页
如何引用JavaScript

如何引用JavaScript

作者: YANGXIAOFEI | 来源:发表于2018-02-10 11:15 被阅读0次

    内部引用

    < ! 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!";
    }

    相关文章

      网友评论

          本文标题:如何引用JavaScript

          本文链接:https://www.haomeiwen.com/subject/cylctftx.html