Once the user has reached the end of a page, what is the best way to guide them to another specific page?

Is there a way to set up the page so that when the user reaches the bottom, scrolling again will automatically take them to another specific page?

For example, if a user scrolls to the end of page A, then scrolls further at the bottom, they are taken to page C. What is this feature called? Can it be achieved with jQuery?

I don't have any HTML or code samples because I am simply wondering if a jQuery function exists for this purpose. How can I share the entire HTML code of a page?

Answer №1

JQuery:

$(window).scroll(function() {
   if ($(window).scrollTop() + $(window).height() == $(document).height()) window.location = "page2.html";
});

Vanilla JS Desktop:

window.onscroll = function(ev) {
    if ((window.innerHeight + window.scrollY) == document.body.offsetHeight) window.location = "page2.html";
};

Vanilla JS mobile:

document.body.ontouchmove = function(e) {
    if ((window.innerHeight + window.scrollY) == document.body.offsetHeight) window.location = "page2.html";
};

I have not tested this code on mobile as of yet. Hopefully, it functions correctly!

Answer №2

Utilize the following code snippet to implement a feature that detects when the user has reached the bottom of the page:

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert("You have reached the bottom of the page!");
   }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Experience real-time updates in Internet Explorer

$('#<%=ddl.ClientID%>').on("change", function () { displayLoadingPanel(); }); ddl refers to a dropdownlist. Whenever the selected value in the dropdownlist changes, I want to show a loading panel. This code works well in all browsers excep ...

Despite the presence of a producer and topic, sending Kafka messages is proving to be a challenge

Currently, I am using TypeScript and the KafkaJS library on my local machine with a single Kafka broker. After successfully connecting a producer, confirming the creation of my topic, and creating messages like so: const changeMessage = { key: id, ...

Locate the initial ancestor element that contains a specific child element on the first level

Looking to retrieve the primary parent element of a selected item that contains a checkbox as a direct child. HTML $('input[type="checkbox"]').change(function(e) { $(this) .parent() .parents("li:has(input[type='checkbox'] ...

How to implement Google Maps location search by name using PHP

Hi there, I'm new to working with the Google Maps API and I want to display the locations of certain places on a map. The only information I have in my database are the names of these places. Essentially, I want to add a marker to the location based o ...

The concept of recursively exporting modules in Node.js modules

Looking for a way to recursively export all .hbs files in a NodeJS 14+ project main JS. I attempted the following: module.exports = () => ({ partial : __dirname + "/../partial/**.hbs", helper : __dirname + "/../helper/*.js" } ...

An error occurred with the authorization headers when attempting to retrieve the requested JSON

I am attempting to retrieve JSON data from the Bing Search API. Here is what I have implemented: <!DOCTYPE html> <html> <body> <p id="demo"></p> <script language="JavaScript" type="text/javascript" src="jquery-1.12.3.js"& ...

Making an XHR request prevents other AJAX requests from executing

While testing my website tonight, I came across a bug on an image page. The rest of the page functions correctly - I am able to change the status of images, delete them, and navigate to other pages without any issues. The navigation part of the page grabs ...

Transferring HTML documents using the Express framework

I'm currently developing a small website that includes a subscription list for sending emails using Node and Express. One issue I've encountered is with providing users an unsubscribe link. app.get('/unsubscribe', ... ...); My goal i ...

Guide to embedding Echarts into Vuejs applications

I am looking to incorporate echarts into a template with a specific folder structure: ecomponents---->BarCharts.js Vue-Echarts.vue The code written in BarCharts.js is as follows: import { IEcharts } from 'vue-echarts-v3/src/full.js'; const ...

Flexbox transforms Safari's Horizontal Nav into a Vertical layout

Issue with Horizontal Navigation Bar Turning Vertical in Safari I've been using flexbox to adjust the spacing and size of the li elements as the browser window size changes. Everything works perfectly fine in Chrome and Firefox, but for some reason, i ...

What is the best method for removing table rows with a specific class?

I have an html table with several rows, and for some of these rows the class someClass is applied. My question is: How can I delete the rows that have a specific class? <table> <tr class="someClass"> ...</tr> <tr class="someClass"> ...

Issue with sizing and panning when using a combination of Three.js and CSS3Renderer

This issue is specific to Chrome. Here's what I have experimented with: I am utilizing the webGL renderer to position a plane geometry in a 3D environment using threejs. This particular code is running within a class, with the scene as one of its me ...

Updating a validation directive on $watch in AngularJS version 1.2

I created a directive for validation on a multi-select that allows for dynamic length validation of selected items. The directive is used like this: (function() { 'use strict'; angular .module('myModule') .dire ...

I am experiencing issues with my Discord.js bot not creating an invite link

Recently, I delved into discord.js but still have much to learn. While working on a bot, I encountered an issue with generating an invite link for the server. Instead of getting the link as expected, an error message popped up: D:\Discord Shield\ ...

Explain to me the functioning of "return render(request, 'path/path')" in Django

Kindly provide a detailed explanation on the functionality of "return render(request, 'path/path')" in a specific views.py file within Django. MYcode: (views.py) from django.shortcuts import render from basic_app.forms import UserForm,UserProfi ...

What is the proper method to access state following a change in location?

I'm currently dealing with an issue where I need to transition to the state of another controller. I understand that in this scenario I must modify the location to load the desired controller, but how do I specify which state to enter? It's wort ...

What sets apart window.app=new Vue({}) versus const app = new Vue({}) when included in app.js within a Vue.js environment?

What exactly is the difference between using window.app and const app in main.js within Vue? import question from './components/Questions.vue'; Vue.http.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken; window.App = new Vue({ ...

Present Different Content for Visitors Using Ad-Blocking Software

I am currently working on a project that is supported by ads. These ads are subtle and relevant to the content, not obnoxious popups for questionable products. However, since the project relies on ad revenue, users with Ad Blockers unfortunately do not co ...

Steps for sending a value to an AngularJS $http success function

I have a question that is very much like the one posed here: How to pass a value to an AngularJS $http success callback As per Angular.js The $http legacy promise methods success and error have been deprecated. You should use the standard then method ...

Tips for designing a HTML form using classes

I need help styling this form using CSS because I have similar areas like a search submit button that require different classes. Any assistance would be greatly appreciated. <perch:form id="contact" method="post" app="perch_forms"> <perch:cont ...