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 6823613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:48:11+00:00 2026-05-26T21:48:11+00:00

My question is about using Back and Next buttons (of the browser) on an

  • 0

My question is about using Back and Next buttons (of the browser) on an AJAX (dynamical) webpage.

The solution I self came up with:

setInterval(function(){    
                if (location.hash != hash)
                {
                   hash = location.hash;
                   app.url = window.location.href.toString().replace('http://xxxxx.nl/xxxx/#!/','')
                   app.handleURL();
                }
            }, 500);

this function reads the url(hash) and compares it with the last stored url(hash), every 0.5 second. If url has changed (back/next is pushed) it runs handleUrl() which runs more functions to dynamically build my page.

the problem is, this sort of works BUT when I click an html [A] element or when I change the url in an other way (javascript), that content will be loaded TWICE because of the setInterval()… functionality.
How can I build my HTML/Javascript in such way that my content will always be loaded once,

  • once when I push back/next

  • once when I click on an HTML element/use Javascript functions on
    runtime

I searched the sh*t out of google for a solution, plz help!

  • 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-05-26T21:48:12+00:00Added an answer on May 26, 2026 at 9:48 pm

    You don’t need a timer to check it. Just use the onhashchange event, and fire your AJAX calls when the event is called. This event isn’t supported in IE versions below 8, though, so your method seems fine if you need IE support.

    Also, it doesn’t make sense that they’re being called twice for a elements, since there’s no reason for the interval to call your AJAX loader twice just because the hash was changed using an a element. You probably have an event listener attached to the a element which causes it to load the AJAX content, which wouldn’t be needed since you’re detecting any change in the hash, no matter how it was changed.

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

Sidebar

Related Questions

So I asked a question a while back about securing downloads using C# (
I recentely asked a question about using an apply function over two lists. Each
Quick question about using IQueryable objects. Can I do something like that and if
I have a question about using HTTPS in a JBossAS7 web application (a universal
i have a question about using GalleryView. At first, i set five default images
Just a quick question about using select() . I'm using select() to read from
I have a question about using subqueries in an Update statement. My example: UPDATE
I've a question about using sqlSave. How does R map RODBC data in the
I have a question about using multiple .htaccess files - I couldn't find the
@swatkins gave a fantastic answer to his own question about using jQuery templates with

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.