• 网站常用js代码搜集


    1.404页面

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <script href="https://cdn.jsdelivr.net/npm/promise-polyfill@7/dist/polyfill.min.js"></script>
        <script src="https://js.fundebug.cn/fundebug.0.3.4.min.js" apikey="4ff49c050ed0ead32da68d9e21f5923f31cc33c5cae1dcec93b14e03f84505e4"></script>
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
        <meta name=screen-orientation content=portrait>
        <meta name=apple-mobile-web-app-capable content=yes>
        <meta name=format-detection content="telephone=no">
        <meta name=full-screen content=yes>
        <meta http-equiv=X-UA-Compatible content="IE=edge">
        <meta name=renderer content=webkit>
        <meta http-equiv=Pragma content=no-cache>
        <meta http-equiv=Cache-Control content=no-cache>
        <meta http-equiv=Expires content=0>
        <meta name=x5-fullscreen content=true>
        <meta content=yes name=apple-mobile-web-app-capable>
        <meta content=yes name=apple-touch-fullscreen>
        <meta content="telephone=no,email=no" name=format-detection>
        <meta content="modeName=750-12" name=grid>
        <!-- <link rel="shortcut icon" href="/src/assets/common/images/favicon.ico" type="image/x-icon"> -->
        <title>404</title>
        <style>
          html body{
            font-size: 100px;
          }
          .wrap{
            width: 100%;
          }
          .nodata_wrap {
            width: 100%;
            display: block;
            text-align: center;
          }
          .nodata_wrap .pic {
              width: 60%;
              height: auto;
              margin-top: 100px;
            }
            .nodata_wrap .text {
              font-size: 20px;
              color: #666666;
              margin: 0 auto;
            }
            .nodata_wrap .tt{
              font-size: 60px;
              color:#C8E7FE;
              text-align: center;
              margin: 12px auto 30px;
            }
            .blue{
              color:#C8E7FE;
            }
            .nodata_wrap .fz14{
              font-size: 16px;
            }
            .fz30{
              font-size: 30px;
            }
        </style>
        <script type="text/javascript">
          window.onload = function(){
            var $seconds=document.getElementById("seconds");
            var waitTime=5;
            function timeOut() {  
                if(waitTime != 0) {  
                    setTimeout(function() {  
                      $seconds.innerText=(--waitTime);
                      if(waitTime == 0){
                        location.href="./index.html";
                      }  
                      timeOut();  
                    }, 1000);  
                }  
            } 
            timeOut();
          }
        </script>
      </head>
      <body>
        <div class="wrap"> 
          <div class="nodata_wrap">
           <img  src="https://i2.ygimg.cn/cmp/mp/404.png" alt="" class="pic">
           <p class="tt">404</p>
           <p class="text">您要找的页面不见啦,请稍后再试~</p>
           <p class="text"><i class="blue fz30" id="seconds">5</i> 秒后</p>
           <p class="text fz14">自动跳转。   <a href="./index.html" class="blue">评测首页</a></p>
         </div>
        </div>
        <!-- built files will be auto injected -->
      </body>
    </html>

    1.若是手机端打开,则跳转到手机页面

    <script language="javascript">
    
    if(navigator.userAgent.match(/(iPhone|iPod|Android|iTouch)/i)){
    	window.location='http://m.sumargrass.com/';
    }
    </script>
    

     2.window.onload不能重复使用,后面的函数会覆盖前面的。

        (1)若函数不是很多,可如下解决:

    window.onload=function(){

    fun1();

    fun2();

    } 

    (2)自定义功能函数addLoadEvent();

      function addLoadEvent(func){

        var oldonload=window.onload;

        if(typeof window.onload!='function'){   //若window.onload没有绑定函数,则像平时那样添加函数即可

          window.onload=func;

        }else{

          window.onload=function(){     //若window.onload绑定函数,则在匿名函数内,追加

              oldonload();

              func();

                      }

          }

    }

    调用方式:addLoadEvent(fun1);

           addLoadEvent(fun2);

  • 相关阅读:
    SQL Server创建表
    SQL Server创建数据库
    SQL Server创建索引
    SQL Server创建视图
    SQL Server创建存储过程
    SQL Server创建触发器
    Unity3D与VS2008结合,加快Unity3D C#开发!
    c#哈希表的用法
    长沙做网站公司解密如何编写高效率的SQL语句
    高效SQL语句必杀技
  • 原文地址:https://www.cnblogs.com/lanyueff/p/4635974.html
Copyright © 2020-2023  润新知