Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8259459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:52:11+00:00 2026-06-08T02:52:11+00:00

I am writing a single page javascript application using the HTML5 History API. The

  • 0

I am writing a single page javascript application using the HTML5 History API. The application loads content via Ajax and internally maintains state information on the foreground screen using a screen stack.

I want to enable navigation with the back button, but I never want to the forward button to be enabled.

A couple quick bits of information:

  • The user should only ever be able to go back, never forward
  • Pressing browser back button closes the current page screen user is on and reloads the previous one
  • Project is targeted towards the latest version of Chrome only, so other browsers implementations are not important
  • I am using native JavaScript and jQuery only, I would like to do this without History.js

When I load a new screen I run the following line:

history.pushState(screenData, window.document.title, "#");

I bind to the popstate event via jQuery:

$(window).bind("popstate", function(event) {
    if (event.originalEvent.state != null) {
        // Logic that loads the previous screen using my screen stack
    }
}); 

My application’s history management is working, however when I go back the forward button is enabled. I need to figure out how to remove data from history on the popstate event.

Can I do this with replaceState? I’m not sure how to go about doing this…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:52:13+00:00Added an answer on June 8, 2026 at 2:52 am

    Bad Part

    To really disable the forward button, you would have to be able to delete browser history, which is not allowed by all javascript implementations because it would allow sites to delete the entire history, which would never be in the interest of the user.

    Good Part

    This is a bit tricky, but I guess it could work if you want to do custom history. You could just use pushState in the popstate event to make your actual page the topmost history entry. I assume the way you handle your history, your window will never unload. This allows you to keep track of the user history yourself:

    var customHistory = [];
    

    Push every page you load with history.pushState(screenData, window.document.title, "#");, like you did before. Only you add the state to your custom history, too:

    history.pushState(screenData, window.document.title, "#");
    customHistory.push({data: screenData, title: window.document.title, location: '#'});
    

    now if you have a popstate event, you just pop you custom history and push it to the topmost entry:

    window.onpopstate = function(e) { 
      var lastEntry = customHistory.pop();
      history.pushState(lastEntry.data, lastEntry.title, lastEntry.location);
      // load the last entry
    }
    

    Or in jQuery

    $(window).on('popstate', function(e) {
      var lastEntry = customHistory.pop();
      history.pushState(lastEntry.data, lastEntry.title, lastEntry.location);
      // load the last entry
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing single-page web application. Client interacts with server using AJAX retrieving quite complex
I am writing a single page ajax app with ASP.NET MVC - making heavy
I'm writing a little single page app (using knockout.js :-)) whereby i have a
So I just finished writing a single page with html5 boilerplate and everything is
I'm writing a single page application. When the page is initially served, it contains
I am writing a simple Django application and wish to add ajax paging using
We are writing single page app (SPA) in which users connect to different database
I'm using slidesjs to create 5 different slideshows/galleries on a single-page site. They all
I'm writing an asp.net Web Application. I wrote a login page that authenticates a
I am writing an application which is recording some 'basic' stats -- page views,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.