js判断页面第一次加载,第一次加载

来源:互联网 发布:林书豪篮网场均数据 编辑:程序博客网 时间:2024/06/06 05:14
<html><head>    <title>Hello World</title>    <meta charset="utf-8">    <script languang="javascript">        function get_cookie(Name) {            var search = Name + "="            var returnvalue = "";            if (document.cookie.length > 0) {                offset = document.cookie.indexOf(search)                if (offset != -1) {                    // if cookie exists                    offset += search.length                    // set index of beginning of value                    end = document.cookie.indexOf(";", offset);                    // set index of end of cookie value                    if (end == -1)                        end = document.cookie.length;                    returnvalue=unescape(document.cookie.substring(offset, end))                }            }            return returnvalue;        }        function loadPopup(){            console.log(get_cookie("firstload"));            if (get_cookie("firstload")===""){                alert("This is the first time you run this program!");                document.cookie="firstload=true"            }        }    </script></head><body onload="loadPopup()"></body></html> 
原创粉丝点击