简体   繁体   中英

Page title not showing up with infinite-scroll after back button

I implemented the infinite scroll feature of infinite-scroll.com on my Shopify store. It works great so far, just one thing is missing.
In the demo https://infinite-scroll.com/demo/full-page/ if you scroll down to page 2 for example, click on a link and then use the back button, on top of the restored page there is a page title showing "Full page demo - page 2".
This title is missing in my case. It would be a great feature so that the user knows content is missing cause (s)he's not on the first page.
Is this page title part of the infinite-scroll feature? Anyone knows how to get this page title? Thank you so much for your help!

I solved it by adding this script. "section-header__title" ist the class name of my h1 heading. I append the page number to the title if "page=" is inside the url on pageload.

$(document).ready(function() {
  if (window.location.href.indexOf("page=") > -1) {
    var pagenumber = window.location.href.split('page=').pop();
    var elementTitle = $('.section-header__title').first().text();
    elementTitle += ' - Page ' + pagenumber;
    $('.section-header__title').first().text(elementTitle);
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM