e 1 сар өмнө
parent
commit
37bed2615c

+ 1 - 1
3.js初级/BOM/6.location.html

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

+ 74 - 0
3.js初级/DOM/24.下落的树叶.html

@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+    <style>
+      img {
+        position: absolute;
+      }
+    </style>
+  </head>
+  <body>
+    <script>
+      var screenWidth =
+        document.documentElement.clientWidth || document.body.clientWidth;
+      var screenHeight =
+        document.documentElement.clientHeight || document.body.clientHeight;
+      function Leaf() {
+        // 图片的宽度
+        this.width1 = Math.random() * 100 + 100;
+        // 距离顶部的位置
+        this.top1 = 0;
+        // 距离左侧的位置
+        this.left1 = Math.random() * (screenWidth - this.width1);
+        // 图片的路径
+        this.img1 = "./img/" + Math.floor(Math.random() * 4 + 1) + ".png";
+      }
+      Leaf.prototype.init = function () {
+        var imgs = document.createElement("img");
+        imgs.style.width = this.width1 + "px";
+        imgs.src = this.img1;
+        imgs.style.left = this.left1 + "px";
+        imgs.style.top = this.top + "px";
+        this.myImg = imgs;
+        document.body.appendChild(imgs);
+      };
+      var failList = []
+      for (var i = 0; i < 20; i++) {
+        var newLeaf = new Leaf();
+        failList.push(newLeaf)
+        newLeaf.init();
+      }
+
+      Leaf.prototype.fail = function () {
+        // console
+        setTimeout(
+          function () {
+            var timer = setInterval(
+              function () {
+                if (
+                  this.myImg.offsetTop <
+                  screenHeight - this.myImg.offsetHeight
+                ) {
+                  this.myImg.style.top = this.myImg.offsetTop + 10 + "px";
+                } else {
+                  clearInterval(timer);
+                }
+              }.bind(this),
+              20
+            );
+          }.bind(this),
+          Math.random()*3000
+        );
+      };
+
+      document.onclick = function () {
+        for(var i=0;i<failList.length;i++) {
+            failList[i].fail()
+        }
+      };
+    </script>
+  </body>
+</html>

+ 1 - 1
3.js初级/DOM/5.选项卡.html

@@ -74,7 +74,7 @@
           contain[this.index].className='active choose'
         };
       }
-    //  onmousemove onmouseout
+    //  onmousemove onmouseout onclick
     </script>
   </body>
 </html>