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);
}
})
Jquery detect page refresh的更多相关文章
- Part 31 AngularJS page refresh problem
What is the issue : When you navigate to http://localhost/students, you will see list of students as ...
- jQuery - Detect value change on hidden input field
You can simply use the below function, You can also change the type element. $("input[type=hidd ...
- 使用 jQuery 调用 ASP.NET AJAX Page Method
文章来源:http://chungle.iteye.com/blog/406054 说到轻量级的客户端通信,我注意到大多数人喜欢使用 ASP.NET AJAX Page Method 多于 ASMX ...
- 转载:10+ handy and reusable jQuery code snippets
源地址:http://www.catswhocode.com/blog/10-handy-and-reusable-jquery-code-snippets Smooth scrolling to t ...
- jQuery Mobile 脚本加载问题
刚开始使用jQuery Mobile,发现很多问题需要重新考虑,比如脚本加载问题. 在普通html中,如果a.html中有链接到b.html,b.html中有类似代码: $(document).rea ...
- jquery插件 源码
下面是对Jquery几个经常用到的地方进行的增强. 功能是参考百度七巧板JS框架来完成的. 一.页面属性 $.page.getHeight():获取页面高度 $.page.getWidth():获取页 ...
- [转]Load ASP.NET MVC Partial Views Dynamically Using jQuery
本文转自:http://www.binaryintellect.net/articles/218ca630-ba50-48fe-af6e-6f754b5894aa.aspx Most of the t ...
- jQuery Ajax Post Data Example
http://www.formget.com/jquery-post-data/ jQuery Ajax Post Data Example Fugo Of FormGet jQuery $.post ...
- 【转】2014年25款最好的jQuery插件
2014年25款最好的jQuery插件 来源:Specs' Blog-就爱PHP 时间:2014-12-30 10:24:10 阅读数:2267 分享到: 0 http://www.php10 ...
随机推荐
- vue-progressbar 知识点
使用步骤: 安装 import.Vue.use() 组件里,created() 和 mounted() 复制官方github地址上的代码 官方github地址:https://github.com/h ...
- RESTful 接口设计规范
get 用来获取,post 用来新建(也可以用于更新),put 用来更新,delete 用来删除.
- Angular 4 http通讯 解决服务器参数无法接收问题
1.导入 import { Component, OnInit } from '@angular/core'; import {Observable} from 'rxjs/Observable'; ...
- 阿里巴巴Java开发手册- 控制语句
1. [强制]在一个 switch 块内,每个 case 要么通过 break / return 等来终止,要么注释说明程序将继续执行到哪一个 case 为止 : 在一个 switch 块内,都必须包 ...
- 【python】class之super关键字的作用
在Python类的方法(method)中,要调用父类的某个方法,在Python 2.2以前,通常的写法如代码段1: 代码段1: class A: def __init__(self): prin ...
- 惠普(HP)战66 Pro G1 - 批量GHOST[Win10专业版 ] (UEFI)
笔记本型号:惠普(HP)战66 Pro G1 14英寸轻薄笔记本电脑(i5-8250U 8G 256G PCIe SSD+500G 标压MX150 2G独显)银色 需求: 公司一共采购10台笔记本,需 ...
- java IO字符流
字节流:因为内存中数据都是字节,二进制数据. 字符流:方便处理文本数据.字符流是基于字节流的. ascii 编码表,并且各国都有自己的编码表. unicode码表,世界码表.优化后 utf-8码表. ...
- my sql 只展示 前10条数据的写法
select * from 表 where 条件 limit 10 这里想看多少条 limit 后面的数字就是多少
- jenkins 使用的python 不是指定的python 的解决方法
构建的时候加上要使用python的解析器路径 终端 which python 可以找到 python编辑器里面 import os os.system("which python" ...
- 2018-2019 20165226 网络对抗 Exp1 PC平台逆向破解
2018-2019 20165226 网络对抗 Exp1 PC平台逆向破解 目录 一.逆向及Bof基础实践说明 二.直接修改程序机器指令,改变程序执行流程 三.通过构造输入参数,造成BOF攻击,改变程 ...