jQuery Reload live Page和Stop?

时间:2011-08-04 14:23:34

标签: refresh reload jquery

我正在检查一个网址是否包含“重写”一词,如果是,我正在添加一个cookie。但是,我想在添加cookie后重新加载页面,然后停止重新加载页面。目前它不断重新加载页面,因为它看到了URL并且它包含单词“rewrite”。在jQuery或Do Once方法中有Stop()吗? Perhpas我必须使用.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();
}

1 个答案:

答案 0 :(得分:1)

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

相关问题