检查是否是上一节fullPage.js

Sso*_*esS 3 javascript fullpage.js

我在网站上使用整页插件,这是我的标记

<div id="fullpage">
  <div class="section section1">Some section</div>
  <div class="section section2">Some section</div>
  <div class="section section3">Some section</div>
  <div class="section section4">Last section</div>
</div>
Run Code Online (Sandbox Code Playgroud)

在我的网站上,我想执行以下操作:用户将向下滚动每个部分,当用户到达最后一个部分时,我要将用户重定向到另一个页面,如何检查用户在fullpage.js中的最后一个部分中?

Max*_*ter 5

您可以在整页中使用此afterLoad功能来实现此目的。以下代码段将使您了解如何afterLoad检查用户是否在最后一节中,并在需要时进行重定向:

$('#fullpage').fullpage({
        ...

        afterLoad: function(anchorLink, index){
            // Section indexes in fullpage start at 1
            if(index === $('#fullpage .section').length){
                window.location.href = "http://stackoverflow.com";
            }
        }

        ...
    });
Run Code Online (Sandbox Code Playgroud)