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
Solution Beyondspace Posted July 21, 2021 Solution 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) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations) 🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget 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! Beyondspace 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment