e il y a 1 an
Parent
commit
86e5bed297

+ 29 - 0
JS初级/BOM/4.history.html

@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+  </head>
+  <body>
+    <!-- 
+        back() 加载 history 列表中的前一个 URL
+        forward() 加载 history 列表中的下一个 URL
+        go(num) 加载 history 列表中的某个具体页
+     -->
+     <a href="./4_1.history.html">附页</a>
+     <button id="btn1">下一页</button>
+     <button id="btn2">上一页</button>
+     <script>
+        var btn1 = document.getElementById("btn1");
+        btn1.onclick = function(){
+            // history.forward();
+            history.go(1)
+        }
+        var btn2 = document.getElementById("btn2");
+        btn2.onclick = function() {
+            history.go(1);
+        }
+     </script>
+  </body>
+</html>

+ 19 - 0
JS初级/BOM/4_1.history.html

@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    这是一个附页
+    <button id="btn">返回</button>
+    <script>
+        var btn = document.getElementById("btn");
+        btn.onclick = function() {
+            // history.back();
+            history.go(-1)
+        }
+    </script>
+</body>
+</html>

+ 21 - 0
JS初级/BOM/5.Location对象.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+  </head>
+  <body>
+    <script>
+        //hash 设置或返回从井号 (#) 开始的 URL(锚)
+        //host 设置或返回主机名和当前 URL 的端口号
+        //hostname 设置或返回当前 URL 的主机名
+        //href 设置或返回完整的 URL
+        //pathname 设置或返回当前 URL 的路径部分
+        //port 设置或返回当前 URL 的端口号
+        //protocol 设置或返回当前 URL 的协议
+        //search 设置或返回从问号 (?) 开始的 URL(查询部分)
+        console.log(location.host);
+    </script>
+  </body>
+</html>

+ 26 - 0
JS初级/BOM/6.Navigator对象.html

@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <!-- 
+        appCodeName 返回浏览器的代码名
+        appName 返回浏览器的名称
+        appVersion 返回浏览器的平台和版本信息
+        browserLanguage 返回当前浏览器的语言
+        cookieEnabled 返回指明浏览器中是否启用 cookie 的布尔值
+        cpuClass 返回浏览器系统的 CPU 等级
+        onLine 返回指明系统是否处于脱机模式的布尔值
+        platform 返回运行浏览器的操作系统平台
+        systemLanguage 返回 OS 使用的默认语言
+        userAgent 返回由客户机发送服务器的 user-agent 头部的值
+        userLanguage 返回 OS 的自然语言设置
+     -->
+     <script>
+        console.log(navigator.appName);
+     </script>
+</body>
+</html>

+ 25 - 0
JS初级/BOM/7.补充.html

@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+  </head>
+  <body>
+    <span>1</span>
+    <span>2</span>
+    <span>3</span>
+    <span>4</span>
+    <span>5</span>
+    <div class="btn1">啊啊啊</div>
+    <script>
+        // 获取同一元素所有标签
+        console.log(document.querySelectorAll("span"));
+        console.log(document.querySelectorAll(".btn1"));
+        // console.log(document.getElementById("btn1"));
+        // 添加节点内容
+        var spanList = document.querySelectorAll("span");
+        spanList[2].innerText = '我的'
+    </script>
+  </body>
+</html>