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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:51:58+00:00 2026-06-07T20:51:58+00:00

I am stripping url with document.location.hash and trying to check whats left behind from

  • 0

I am stripping url with “document.location.hash” and trying to check whats left behind from current url. I dont want to use any plugin and dont want to learn result from trigger events like click. Need to learn url change instantly and contemporary.

jQuery:

$(function() {
    $(document).location().change(function() {//this part is not working
        var anchor = document.location.hash;
        if( anchor === '#one' ) {
            alert('current url = #one');
        }else if ( anchor === '#two' ) {
            alert('current url = #two');
        }else if ( anchor === '#three' ) {
            alert('current url = #three');
        }
        console.log(anchor);
    });
});

html:

<a href="#one">one</a>
<a href="#two">two</a>
<a href="#three">three</a>

deep note: i have read these questions and cout find what i am looking for:
How to detect URL change in JavaScript + How to change the current URL in javascript?

  • 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-07T20:52:00+00:00Added an answer on June 7, 2026 at 8:52 pm

    Without using a plugin other than jQuery, you can handle the ‘hashchange’ event:

    $(document).ready(function() {
        $(window).bind( 'hashchange', function(e) { 
        var anchor = document.location.hash;
                if( anchor === '#one' ) {
                    alert('url = #one');
                }else if ( anchor === '#two' ) {
                    alert('url = #two');
                }else if ( anchor === '#three' ) {
                    alert('url = #three');
                }
                console.log(anchor);
        });
    });
    

    Caution: Not all browsers support the hashchange event.

    Use with fallback: You should use Modernizr to detect if hashchangeEvent is supported and if that support check fails then fallback to Ben Alman’s jQuery hashchange event plugin and use @Baylor Rae’s solution in your else block.

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

Sidebar

Related Questions

Getting TypeError: document.getElementById(free_shipping) is null This is what im trying --- I just want
I'm having problems stripping the tags from the textual inputs retrieved from my form
I am trying to have Zebra stripping for my table but it is not
I have been using HTML Parser to scrapping data from websites and stripping html
By default, the datetime field from the database is being converted and stripping off
It appears as though IE6, IE7, and IE8 are stripping \f (formfeed) characters from
How would I go about trimming/stripping the URL down to the page name... So:
I want to add an automatic embedding feature when a YouTube URL is used
I'm trying to add some JQuery to an ASP.Net User Control to check to
Are there any HTTP Headers I could use to grab the entire referrer URL

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.