码迷,mamicode.com
首页 > 其他好文 > 详细

判断第一次加载

时间:2014-10-21 17:46:13      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:js   首次加载   

<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> 

判断第一次加载

标签:js   首次加载   

原文地址:http://blog.csdn.net/gisshixisheng/article/details/40347135

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!