zoukankan      html  css  js  c++  java
  • js funciton总结

    1.窗口每个一段时间加载 window.location.reload() 或者加上标签<meta http-equiv="refresh" content="1">代表一秒自动刷新,用在一些实时显示的网站比如股票等。

    2.前进和后退,window.history.forward() window.history.back()

    3.若干秒后自动关闭,设置一个flag,然后body上加个事件,用来改变这个flag,如果事件触发重置flag

    var willClose = true;
    function clickBody(){
          willClose = false;    
    }
    setInrerval(function(){
           if(willClose){window.close()}else{willClose = true}
    },10000)    
    View Code

    4.修改网页标题, document.title = value.

    5.动态加载js,

    function(){
         var theHead = document.getElementByTagName('head').item(0);
         var myScript = document.createElement('script');
         myScript.src = ''
         myScript.type = 'text/javascript'
         myScript.defer = true;//设置加载完成之后在解析执行
    }
    View Code

    6.判断页面是否加载完毕,window.onload但是网页加载完毕包括的是所以的都加载完毕,但是我们可能需要文档加载完毕做操作,那么就要用document的onreadystatechange监听

     document.onreadystatechange = myOnload;
        function myOnload(){
            if(document.readyState == 'complete'){
                alert('文档加载完毕')
            }
        }
    View Code
    zhumiao
  • 相关阅读:
    js闭包
    python切片 []取值操作符
    python with语句
    python鸭子类型(duck type)
    python编码规范
    python @property使用详解
    python __slots__使用详解
    Python面向对象编程
    ifconfig命令详解
    5、Cocos2dx 3.0游戏开发找小三之測试例子简单介绍及小结
  • 原文地址:https://www.cnblogs.com/zhumiao/p/9540321.html
Copyright © 2011-2022 走看看