JS——三种嵌入页面的方式

一 行间事件

二 页面script标签嵌入

三 外部引入

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <!--第三种嵌入js的方式:外链式。程序从上面读到这里,这句话就会被执行-->
    <script type="text/javascript" src="hello.js"></script>

    <!--第二种嵌入js的方式:嵌入式。程序从上面读到这里,这句话就会被执行-->
    <script type="text/javascript">

        alert('hello,again!');
    </script>
</head>
<body>
    <!--每一个标签都有一个事件属性-->
    <!--第一种嵌入js的方式:行间事件,不推荐使用-->
    <input type="button" name="" value="弹框" onclick="alert('hello!')">
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/gaoquanquan/p/9182089.html