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 ...
随机推荐
- window.open 和 location.href 区别
window.open():可以在一个网站上打开另外的一个网站的地址 window.location():只能在一个网站中打开本网站的网页
- django模板里关闭特殊字符转换,在前端以html语法渲染
变量 pagination_html是一个方法返回的html代码,需要在前端渲染出来,不是当字符串显示 <!-- /.box-body --> {% autoescape off %} { ...
- Apache关闭VirtualHost的Log日志记录
有时我们的apache产生的日志是超大的并且 没什么用处,这时我们就可以关闭了,关闭apache日志很简单,直接ErrorLog off或 # CustomLog即可. Web server(ex: ...
- 洛谷1352没有上司的舞会——树型dp
题目:https://www.luogu.org/problemnew/show/P1352 #include<iostream> #include<cstdio> using ...
- Python——面向对象、绑定对象、组合
1. 面向过程VS面向对象 (1)面向过程 核心是过程(流水线式思维),过程即解决问题的步骤,面向过程的设计就好比精心设计好一条流水线,考虑周全什么时候处理什么东西. 优点是:极大的降低了写程序的复杂 ...
- jcFlexible.js的小Demo
;(function(win, lib) { var doc = win.document; var docEl = doc.documentElement; var metaEl = doc.que ...
- AIX6.1 线程模型说明
引文:线程模型(Threading Model)默认从进程域 (M:N 模型 ) 改为系统全局域 (1:1 模型 ) 在 AIX 5L 中,pthread 线程的默认模型是 m:n 方式,而从 AIX ...
- BASIC-24_蓝桥杯_龟兔赛跑预测
示例代码: #include <stdio.h> int main(void){ int t1 = 0 , t2 = 0 , l1 = 0 , l2 = 0 ; int v1 = 0 , ...
- 我的Quartz笔记
代码: package com.smt.autorun; import java.io.File; import java.util.ArrayList; import java.util.Date; ...
- HDU 1269 迷宫城堡(向量)(Tarjan模版题)
迷宫城堡 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...