zoukankan      html  css  js  c++  java
  • Jquery detect page refresh

    first thing there are 3 functions we will use:

    function setCookie(c_name, value, exdays) {
                var exdate = new Date();
                exdate.setDate(exdate.getDate() + exdays);
                var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
                document.cookie = c_name + "=" + c_value;
            }
     
        function getCookie(c_name) {
            var i, x, y, ARRcookies = document.cookie.split(";");
            for (i = 0; i < ARRcookies.length; i++) {
                x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
                y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
                x = x.replace(/^s+|s+$/g, "");
                if (x == c_name) {
                    return unescape(y);
                }
            }
        }
     
        function DeleteCookie(name) {
                document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
            }

    Now we will start with the page load:

    $(window).load(function () {
     //if IsRefresh cookie exists
     var IsRefresh = getCookie("IsRefresh");
     if (IsRefresh != null && IsRefresh != "") {
        //cookie exists then you refreshed this page(F5, reload button or right click and reload)
        //SOME CODE
        DeleteCookie("IsRefresh");
     }
     else {
        //cookie doesnt exists then you landed on this page
        //SOME CODE
        setCookie("IsRefresh", "true", 1);
     }
    })
  • 相关阅读:
    NB-IOT终端应用场景
    开关量是什么信号,模拟量是什么信号
    模拟量设备为什么都用4~20mA传输信号
    物联网三大关键技术
    4~20mA.DC(1~5 V.DC)信号制的优点
    Lora在局域网中的优势
    NB-IoT终端在不同工作状态下的分析
    4G模块的串行AT命令发送未接收返回如何处理
    前端性能优化
    Tab:不可思议的CSS光标下划线跟随效果
  • 原文地址:https://www.cnblogs.com/toSeeMyDream/p/5575279.html
Copyright © 2011-2022 走看看