what i'm trying flush localstorage when user move other page.
for example, let i'm in http://foo.com/accounts/mypage.
when user moves url, http://foo.com/album, want flush localstorage.
this jquery script.
$(window).unload(function(){ if ((window.location.pathname).indexof('mypage') < 0) { localstorage.flush(); } }); but doesn't work......
any other nice idea?
add click handler links, this:
var lastlink = ""; $("body").on("click", "a", function() { lastlink = $(this).attr("href"); }); this click run before unload event , able use lastlink value. make sure take account relative urls well.
//todo: implement function ismine $(window).unload(function() { if (ismine(lastlink)) { localstorage.clear(); } });
Comments
Post a Comment