e 1 년 전
부모
커밋
459eedb2ce
4개의 변경된 파일68개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      js/BOM/6.Navigator对象.html
  2. 1 0
      js/BOM/7.Location对象.html
  3. 33 0
      js/BOM/8.Math对象.html
  4. 33 0
      js/BOM/9.倒计时.html

+ 1 - 0
js/BOM/6.Navigator对象.html

@@ -18,6 +18,7 @@
         // systemLanguage 返回 OS 使用的默认语言
         // userAgent 返回由客户机发送服务器的 user-agent 头部的值
         // userLanguage 返回 OS 的自然语言设置
+        console.log(navigator.appVersion)
     </script>
 </body>
 </html>

+ 1 - 0
js/BOM/7.Location对象.html

@@ -15,6 +15,7 @@
         //port 设置或返回当前 URL 的端口号
         //protocol 设置或返回当前 URL 的协议
         //search 设置或返回从问号 (?) 开始的 URL(查询部分)
+        console.log(Location.host);
     </script>
 </body>
 </html>

+ 33 - 0
js/BOM/8.Math对象.html

@@ -0,0 +1,33 @@
+<!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>
+        // Math 对象
+        document.write(Math.PI + '<br>')//常量
+        document.write(Math.E)//常量
+        var a = 4.6;
+        // Math.ceil 向上取整
+        console.log(Math.ceil(a))
+        // Math.floor 向下取整
+        console.log(Math.floor(a))
+        // Math.abs 向上取整
+        console.log(Math.abs(a))
+        // Math.round 四舍五入
+        console.log(Math.round(a))
+        // Math.random 随机数
+        console.log(Math.random())
+        // Math.round(Math.random() * (y-x) + x)
+        // 四舍五入 随机获取 3-10的整数
+        console.log(Math.round(Math.random() * (10-3) + 3));        
+        console.log(Math.sqrt(81)); // Math.sqrt 算数平方根
+        console.log(Math.pow(2,3));//Math.pow x的y次幂
+
+
+    </script>
+</body>
+</html>

+ 33 - 0
js/BOM/9.倒计时.html

@@ -0,0 +1,33 @@
+<!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>
+      // 字面量 1 2 3 4 56 true false
+      // 变量
+      var a = 3;
+      function time() {
+        // 倒计时
+        // 逻辑:结束时间 开始时间
+        // 时间无法直接运算 转换成时间戳(毫秒)
+        var start = new Date().getTime();
+        var end = new Date("2024-04-20 19:00").getTime();
+        // console.log(start);
+        // console.log(end);
+        var diffTime = (end - start) / 1000;
+        var day = Math.floor(diffTime / 60 / 60 / 24);
+        var hour = Math.floor((diffTime / 60 / 60 ) % 24);
+        var minutes = Math.floor((diffTime / 60) % 60);
+        var seconds = Math.floor(diffTime % 60);
+        console.log(day + '天'  + hour + '小时' + minutes + '分' + seconds + '秒')
+      }
+      setInterval(function(){
+        time();
+      },1000)
+    </script>
+  </body>
+</html>