MayaViolet Posted July 21, 2021 Share Posted July 21, 2021 Hey y'all - very new to jquery here. I found this jquery posted on Stack Overflow on how to redirect the user to a new page once they have scrolled to the bottom of the original page with the following code: $(window).scroll(function() { if ($(window).scrollTop() + $(window).height() == $(document).height()) window.location = "page2.html"; }); However, I'd like the function to delay for about 2 seconds so the transition isn't so jarring. I've tried to implement setTimeout, but still don't have a solid grasp on jQuery syntax/language to figure it out. Would love any help, thank you! Link to comment
Beyondspace Posted July 21, 2021 Share Posted July 21, 2021 $(window).scroll(function() { if ($(window).scrollTop() + $(window).height() == $(document).height()) { setTimeout(function() { window.location = "page2.html"; }, 2000); } }); try BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace (+100 Spark plugin customisations) 🥳 Freemium Squarespace Widget Templates (+1000 Elfsight Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
MayaViolet Posted July 22, 2021 Author Share Posted July 22, 2021 3 hours ago, bangank36 said: $(window).scroll(function() { if ($(window).scrollTop() + $(window).height() == $(document).height()) { setTimeout(function() { window.location = "page2.html"; }, 2000); } }); try Ahh - that placement makes a lot of sense. That worked, thanks so much for your help! Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.