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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:31:31+00:00 2026-06-14T15:31:31+00:00

Example: http://localhost/#view=1 If I want to get that variable view, I need to get

  • 0

Example:

http://localhost/#view=1

If I want to get that variable “view”, I need to get window.location.href, and then split the # and do something more.

This is my question:

<a href="#view=1">View 1</a>
<a href="#view=2">View 2</a>

Is there anyway to detect when View 1 click or view 2 click? For people click on View 2, a function will do for view=2.

OR I must do something like this:

<a href="#view=1" onclick="setview(1);">View 1</a>
<a href="#view=2" onclick="setview(2);">View 2</a>

I want when people copy the link http://localhost/#view=2 and send to there friend, the function setview(2) will be run when their friend visit the URL, and they don’t need to click the link.

  • 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-14T15:31:32+00:00Added an answer on June 14, 2026 at 3:31 pm

    You can use hashChange event

    $(function(){
      // Bind the event.
      $(window).hashchange( function(){
        // Alerts every time the hash changes!
        alert( location.hash );
      })
    
      // Trigger the event (useful on page load).
      $(window).hashchange();
    });
    

    And now in the $(window).hashchange(); function, put your code:

    $(window).hashchange(function(){
      $(location.hash).show();
    });
    

    In your case, it would be:

    $(window).hashchange(function(){
      setview(location.hash[strlen(location.hash)-1]); // Get the last character, if this doesn't work.
    });
    

    Forgot to add the plugin: http://benalman.com/projects/jquery-hashchange-plugin/, which you would need to use.

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

Sidebar

Related Questions

For example I am on page http://localhost:1338/category/category1?view=list&min-price=0&max-price=100 And in my view I want to
I need to call an API with POST arguments, for example: URL = http://localhost/myAPI/
For example I have site http://localhost/site In IIS I set that 404 error causes
Please give me example how to generate ActionLink with reditection to: http://localhost/Articles?View=xx instead of
I've an example sencha touch2 application. It is working fine in my localhost browser(http://localhost/sencha/examples/navigationview/index.html).
Example: http://bit.ly/dfjvmT If you take a look at that URL, you will see an
Example: http://jqueryui.com/demos/dialog/#modal-confirmation The example shown allows you to view the source and even has
Example: http://soundcloud.com/torsmusic/emancipator-siren-tor-remix You will notice that if you click play, the favicon dynamically displays
I have a Pyramid app that I've been developing and viewing locally through http://localhost:6543
I'm trying to get http://localhost:8080/test to map to the index.jsp page. The jsp file

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.