开发者

jQuery Reload live Page and Stop?

I am checking to see if a url contains the word "rewrite", if it does I am adding a cookie. However, I want to reload the page after the cookie is added, then stop reloading the page. Currently it keeps reloading the page because it sees the url and it contains the w开发者_运维百科ord "rewrite". Is there like a Do Once in jQuery or a Stop() method? Perhpas I have to use .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();
    }
});

SOLVED

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


Check for rewrite in the URL AND the cookie, if both then you know you've already done the reload?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜