检测第一页加载的jQuery会议 [英] detect first page load jquery session

查看:96
本文介绍了检测第一页加载的jQuery会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用户登录时,我显示基于页面加载方法的检查警报用户。现在,当用户浏览到其他aspx页面并点击回家再说,我不想让他再次看到该警报。我想用jQuery和会话变量来实现这一目标。在某种程度上,我想通过jQ​​uery的使用会话变量来检查第一页的负荷。

Once the user logs in, i am displaying an alert to user based on a check on page load method. Now when the user navigates to other aspx pages and clicks on home again, I don’t want him to see the alert again. I want to achieve this with jquery and session variable. In a way I want to check first page load by jquery using a session variable.

推荐答案

我几个星期前做这个确切功能,但用来代替使用会话一个MySQL数据库。如果你是想显示警报给用户只有一次EVER(或接近永远越好),或只是每周一次等,那么你应该使用,而不是会议的cookies。

I made this exact feature a couple of weeks ago, but used a mySQL database instead of using sessions. If you are wanting to display the alert to the user only once EVER (or as close to forever as possible) or just once a week etc, then you should use cookies instead of sessions.

另外,你可以检测当页面已经使用jQuery简单加载:

Otherwise, you can detect when the page has loaded simply with jQuery:

$().ready(function(){
    if(!$.session.get("viewed_page")){
        alert("some message"); 
        $.session.set("viewed_page", true);
    }
});

这篇关于检测第一页加载的jQuery会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆