javascript - how to save the scroll state -


i save/determine scroll state(current position) when user comes previous site can continue work position left it.

can continuously save scroll position global variable , read when user comes back?

using javascript, can find out scroll height set cookie. not great way it, it's possible.

finding scroll height:

$(document).ready(function(){     $(window).scroll(function(){        var scrolled = $(this).scrolltop();          console.log(scrolled);     }); }); 

i suggest using jquery cookie plugin set cookie or session: http://archive.plugins.jquery.com/project/cookie http://www.sitepoint.com/eat-those-cookies-with-jquery/

then add variable cookie:

$(document).ready(function(){     $(window).scroll(function(){         $.removecookie("mysitescrolled");         var scrolled = $(this).scrolltop();          $.cookie("mysitescrolled", scrolled);         console.log(scrolled);     }); }); 

then add "check scrolled" statement

$(document).ready(function(){     var scrolled = $.cookie("mysitescrolled");     if(scrolled){         $(window).scrolltop(scrolled);     }     $(window).scroll(function(){         $.removecookie("mysitescrolled");         var scrolled = $(this).scrolltop();          $.cookie("mysitescrolled", scrolled);         console.log(scrolled);     }); }); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -