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

  • SEARCH
  • Home
  • 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 9049899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:31:11+00:00 2026-06-16T12:31:11+00:00

I am loading the page via Ajax. When the user clicks a link the

  • 0

I am loading the page via Ajax. When the user clicks a link the page is being loaded AJAX successfully, but when the user click the back button the pages reloads the initial page. so the scenario is this.

  1. Load the initial page(index.php)
  2. User Clicks on the link
  3. The Page loads Successfully
  4. Clicks the Back button
  5. The initial page is now being shown twice.

Here’s the mark up.

    $(function() {
            // Prepare
            var History = window.History; // Note: We are using a capital H instead of a lower h
            if (!History.enabled) {
                // History.js is disabled for this browser.
                // This is because we can optionally choose to support HTML4 browsers or not.
                return false;
            }

            // Bind to StateChange Event
            History.Adapter.bind(window, 'statechange', function() { // Note: We are using statechange instead of popstate
                var State = History.getState();
                $('#content').load(State.url);
            });

            $('a').click(function(evt) {
                evt.preventDefault();
                History.pushState(null, $(this).text(), $(this).attr('href'));
                alert(State.url)
            });
        });

THis is the markup

   <div id="wrap">
            <a href="page1.html">Page 1</a>
        </div>

        <div id="content">
            <p>Content within this box is replaced with content from
                supporting pages using javascript and AJAX.</p>
        </div>

IF you still do not get my question or the scenario

Here’s the complete scenario.
Initial Page

enter image description here

When the User Clicks the link the selected page loads successfully

enter image description here

When I click the back button the initial page is now doubled

enter image description here

As you can see the “Page1” link is doubled. Is this a browser issue? or my understading of the history api is something lacking or missing? What is the possible solution for 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-16T12:31:13+00:00Added an answer on June 16, 2026 at 12:31 pm

    If you construct your site to use a similar template for both the main pages as well as the content pages, you could use the container selector syntax for jquery.load:

    // See: http://api.jquery.com/load/
    $('#result').load('ajax/test.html #container');
    

    Which in your case would result in:

    $('#content').load(State.url + ' #content');
    

    This will have the added benefit that the content url pages are accessible directly as well without adding to much tricks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am loading in page content via ajax, I am wanting the old content
I'm loading a page dynamically via fancybox and AJAX. Everything is fine except when
I have a Jquery Mobile page into which I'm loading a form via AJAX.
I'm loading Disqus on a page loaded via HTTPS with the following code, as
I have page loading, via AJAX a PHP page into a div. In turn,
My main page loading another page via ajax. Which has javascript file. How do
I'm loading external page via jquery.ajax: $(#mydiv).load(filter.html); content of example.html: <div id=filterdiv><input id=filter name=filter
I'm loading a view page via an $.ajax() call with jQuery. I'm explicitly setting
What happens if a user leaves the page while its processing via Ajax? Will
Can someone please show me the basic syntax for loading a page via AJAX

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.