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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:20:02+00:00 2026-05-21T23:20:02+00:00

I have an ajax webapp (JSF 2.0) that uses hash for navigation. I’ve used

  • 0

I have an ajax webapp (JSF 2.0) that uses hash for navigation.

I’ve used both event firing with help of this answer and setInterval() to check for value change in older browsers (Mainly IE6+7).

The Javascript code that does this:

window.onload = window.onhashchange = function() {
    lastHash = window.location.hash; // To save a refresh on browsers that don't need it.
    var fragment = document.getElementById('fragment');
    fragment.value = window.location.hash;
    fragment.onchange();
}

// Old Browsers That don't support onhashchange...
var lastHash = window.location.hash;
function checkFragment() {
    if (window.location.hash != lastHash) {
        lastHash = window.location.hash;
        var fragment = document.getElementById('fragment');
        fragment.value = window.location.hash;
        fragment.onchange();
    }
}

This works nicely. Meaning, when I change the value of the hash the AJAX app gets the notification and updates.
One instance in which this doesn’t work is IE 6/7. When I press Back/Forward buttons, I can see the url bar gets updated with the correct hash values, but the windows.location.hash doesn’t seem to change and so my SetEvent() function doesn’t detect the change.

Anyone found a solution to this?
Thanks!

  • 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-21T23:20:03+00:00Added an answer on May 21, 2026 at 11:20 pm

    Consider using jQuery Hashchange plugin to avoid IE6/7 compatibility headaches. You can find code example here. It can be altered as follows for your case.

    <script src="jquery.js"></script>
    <script src="jquery-hashchange.js"></script>
    <script>
        $(function(){
            $(window).hashchange(function(){
                $('#fragment').val(location.hash).change();
            });
    
            $(window).hashchange();
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using asp.net MVC to develop an application that will have ajax interactions.
I have an Ajax.Net enabled ASP.Net 2.0 web site. Hosting for both the site
I have some AJAX work that brings across an additional form element that I
I have an AJAX application which has used CSS divs to create panels on
They say that a closed session in hibernate and webapp with ajax is a
I have a little personal webapp that I'm working on. I have a link
I have a webapp written in PHP using a MySQL database backend. This question
This is beyond both making sense and my control. That being said here is
I have an ajax call that refreshes the following table. Can I have the
I have written a web app in PHP which makes use of Ajax requests

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.