【问题标题】:jQuery Reload live Page and Stop?jQuery重新加载实时页面并停止?
【发布时间】:2011-10-20 01:34:07
【问题描述】:

我正在检查一个 url 是否包含“rewrite”这个词,如果是,我正在添加一个 cookie。但是,我想在添加 cookie 后重新加载页面,然后停止重新加载页面。目前它一直在重新加载页面,因为它看到了 url 并且它包含单词“rewrite”。 jQuery 中是否有 Do OnceStop() 方法?也许我必须使用.live()?

$(document).ready(function () {
    if ($.cookie('logged_in') == null) {
        Do Nothing
        } else {
        Do Something
    }
});

$(document).ready(function () {                     
    if (/rewrite/.test(self.location.href)) {
        $.cookie("logged_in", 1, { expires : 1 });
        location.reload(); stop();
    }
});

已解决

if (/rewrite/.test(self.location.href)) {
    if ($.cookie('logged_in') == null) {
        $.cookie("logged_in", 1, { expires : 1 });
        location.reload();
}

【问题讨论】:

    标签: refresh reload jquery


    【解决方案1】:

    检查 URL 和 cookie 中的重写,如果两者都知道,那么您知道您已经完成了重新加载?

    【讨论】:

    • 是的,可以。当然很简单...重新排列代码,谢谢。
    • 如果 (/rewrite/.test(self.location.href) && $.cookie('logged_in') == null) 也可以这样做
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-01
    • 1970-01-01
    • 2011-08-25
    • 2016-02-01
    • 2023-03-13
    • 2020-03-11
    相关资源
    最近更新 更多