jQuery maintaining state across pages. jQuery cookie plugin?
background
i am actually creating an infinite page scroller in jQuery for my tumblr. i want users to be able to disable this functionality. maybe enable it again if they want, thats later.
problem so far
i can disable the auto loading of new pages using a link that will unbind()
the scroll()
event. also it sets a variable infiniteScrollingEnabled = false
so that my script will not append loaded data to the page.
$("#btnDisable").click(function() {
$window.unbind("scroll", infiniteScroll);
$(".load开发者_StackOverflowing", postsSelector).fadeOut("slow");
isLoading = false;
infiniteScrollEnabled = false;
});
but when u user goes to a new page via a link, infinite scrolling is enabled again. to fix this i guess i need cookies.
solution considered
jQuery cookie plugin
question
how can i find out dynamically what is the domain i shld use? or is there a need to set that option?
You can get the domain of the current page using standard javascript: window.location.hostname
(or window.location.host
if you want to include any port that may be specified).
精彩评论