Jquery detect page refresh
2016-06-11 14:24
495 查看
first thing there are 3 functions we will use:
Now we will start with the page load:
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 $符号的冲突
- H5选择器之大放异彩 仿jquery链式调用 IE8+完美运行
- jquery动画之slide
- jquery.cookie用法
- jQuery之锚点带动画跳转特效
- jquery对所有<input type="text"的控件赋值
- jquery easyui 显示和关闭数据加载的遮罩
- document.body.innerHTML用jquery如何表示
- aptana studio 3支持jquery
- jQuery 3.0正式发布
- jQuery自定义数值抽奖活动代码
- jQuery 3.0 发布!根本不支持 IE6/7/8
- webService学习9:jquery ajax调用webservice
- jquery与php的json交互
- firefox和chrome中 JQuery的ajax组件执行差异
- 简单的鼠标滑动上去图片放大Jquery特效代码
- 利用jquery给指定的table动态添加一行、删除一行
- 从重置input file标签中看jQuery的 .val() 和 .attr(“value”) 区别
- 关于jquery动画中的淡入淡出的理解
- jQuery 常用动画