【发布时间】:2011-10-20 01:34:07
【问题描述】:
我正在检查一个 url 是否包含“rewrite”这个词,如果是,我正在添加一个 cookie。但是,我想在添加 cookie 后重新加载页面,然后停止重新加载页面。目前它一直在重新加载页面,因为它看到了 url 并且它包含单词“rewrite”。 jQuery 中是否有 Do Once 或 Stop() 方法?也许我必须使用.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();
}
【问题讨论】: