is it possible to create a redirect only after the page has been scrooled, for example, in the middle and redirects to another page? I tried various solutions and plugins but couldn't find anything that suited me
1 Answer
Try this solution: You can easily do this by using jQuery.
jQuery(document).scroll(function() {
var y = $(this).scrollTop();
if (y > 800) {
window.location.replace("http://stackoverflow.com");
} else {
console.log('test');
}
});
-
-
Just put this in the footer.php before the </footer> closing tag Commented Mar 4, 2022 at 20:42
-
if I put it in the footer all the pages will have the redirect, I have to do it only for a specific page and above all there must be this redirect after I have reached the middle of the page with the scroll Commented Mar 5, 2022 at 11:30
-
You can use the "page id" or is_page function and under that you can put the script. Commented Mar 7, 2022 at 14:49