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 ...
随机推荐
- jsp 知识点
在JSP中很多对象是不需要创建的,如out.session等.它们可以直接使用. <% out.println(session.getId()); %>
- Python与机器学习
pandas里面的对于数据操作比如where,drop以及dropna等都会有一个属性:inplace,这个单词意思是原地,如果inplace=true代表数据本身要返回(原地数据也会被改变):如果i ...
- I2C子系统驱动框架及应用 (转)
I2C子系统驱动框架: 应用程序层(app层) ——————————————————————————————————– i2c driver层: 从设备驱动层(TS Sensor等) 1. ...
- windows server 2008 修改域的密码策略
1.一般情况下,进入本地安全策略修改密码策略时,,密码策略已经被锁定,无法更改,若要修改域服务器上的密码策略,请按照步骤2--6进行修改 2.在此情况下要改密码策略的过程如下, 进入组策略管理: 3. ...
- nginx在centos & ubuntu上的安装
安装Centos 添加当前账号加入sudoers,具备sudo功能 安装编辑器vim Yum install vim Su root Cd cp /etc/sudoers /etc/sudoers[d ...
- ng-model的用法
参考: http://www.cnblogs.com/guanglin/p/5200097.html http://www.runoob.com/angularjs/ng-ng-cloak.html ...
- [记录]js跨域调用mvc ActionResult扩展
背景 最近2个项目中都用到了js跨域访问的知识,2个项目都需要主站与各个分站之间进行数据交互.状态同步等相关操作.浏览器本身是不允许进行跨域访问,在MVC中我们可以扩展一个方法来实现这个功能.在此大家 ...
- Windows下永久解决数据库乱码 utf8 转 gbk
产生乱码原因 因为windows终端的默认字符集是gbk编码,而mysql数据库是utf8的编码,所以会产生乱码问题 解决乱码问题(临时修改) 询当前数据库默认编码: mysql> show v ...
- SpringAOP基础 - 静态代理设计模式
代理模式在实现过程中,要创建一个接口(社交技巧-接口),代理类(经纪人 - 类)和真实类(范冰冰 - 类)同时实现这个接口. 举个例子: 我们想要找范冰冰吃饭,但是呢,她是大明星,不可能轻易见我们,我 ...
- MySQL优化技巧之四:mysql数据库开发常见问题及优化[转]
mysql 数据库是被广泛应用的关系型数据库,其体积小.支持多处理器.开源并免费的特性使其在 Internet 中小型网站中的使用率尤其高.在使用 mysql 的过程中不规范的 SQL 编写.非最优的 ...