Home  >  Q&A  >  body text

html - 切换页面不刷新的保存状态方法;

不停点加载更多,然后再进入某个条目的页面,返回后还是能返回相同的位置。并且在顶端TAB之间切换,各页面内容也都保持。利用H5切换地址能做到页面不刷新,
//onchange
#/home   切换主页
$("body").html(home)

#/artcle  切换文章页
$("body").html(artcle)

但是页面切换html代码给替换了,如何保存之前的数据和状态还有滚动的位置呢?

迷茫迷茫2741 days ago824

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 15:05:41

    Use localStorage to save scrollTop and data,
    then fill in the data if localStorage has data
    Clear localStorage when leaving the page

    reply
    0
  • Cancelreply