Navigate to a new page at the last slide or after set number of loops

revAPI custom JavaScript to navigate to a link when the last slide is finished or after a set of slider loops.

To use the examples below, click here to learn how you can get your “revapi” name for your slider, and also learn where the custom JavaScript can be added.

Navigate to URL after 2000ms at last slide:

// change "revapi1" to whatever API name is being used for your slider
// change the number "2000" to however many seconds you want to pass before the page changes once the last slide is shown
 
document.addEventListener("sr.slide.afterChange", function (e) {
   if (e.id == revapi1606.id && e.current?.index==revapi1606.maxSlide()-1) 
     setTimeout(() => {
       window.location = 'http://www.yoursite.com/somepage/'; 
     },2000);
});

Navigate to URL at last slide after a set amount of loops (Delay 2000ms):

// change "revapi1" to whatever API name is being used for your slider 
// change the number "2" in "loops === 2" to however many loops you want to pass before the page changes 
// change the number "2000" to however many seconds you want to pass before the page changes once the last slide is shown 

let loops = 0;
document.addEventListener("sr.slide.afterChange", function (e) {
   if (e.id == revapi1606.id && e.current?.index==revapi1606.maxSlide()-1) {
     loops++;
     if (loops==2) 
          setTimeout(() => {
               window.location = 'http://www.yoursite.com/somepage/';
          },2000);
   }
});

Navigate to a new page at the last slide or after set number of loops

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

If you need help with anything related to our plugin, please comment on a post or email me at [email protected].

Liked this Post?
Please Share it!