0

I have some links and when you click on them it navigates to: foo.com/about.php#about2 andfoo.com/about.php#about1

How can I get the #about1 or about2 in Javascript, so if it is #about1 display the content relative to that div, and if it is #about2 display that?

Thanks for your help.

8
  • why do you want to use that? Thats pretty much only used in client side stuff. Commented Nov 26, 2011 at 11:01
  • 2
    sorry, this is not the duplication Commented Nov 26, 2011 at 11:02
  • 4
    funny how the question just got changed from php to JS Commented Nov 26, 2011 at 11:03
  • @JanDragsbaek It is isn't it :). I got two different questions mixed up :P Commented Nov 26, 2011 at 11:04
  • 1
    @TimPost No, it didn't. Revision 1 is already edited. I am very sure that I got here through the PHP tag and that tag isn't present in the history, so it is definitely edited. Commented Nov 26, 2011 at 11:14

2 Answers 2

8

In JavaScript, is called window.location.hash

Sign up to request clarification or add additional context in comments.

Comments

3

You can try this

window.location.hash

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.