0

i wanted to know how do you get

http://wesitename.com#overall

How to make a div show when the link is #overall ?

1
  • Can you clarify? what "link"? Commented Jul 17, 2009 at 12:07

2 Answers 2

8

If the div has an id with the same name, then this should work:

$("#"+location.hash).show();

location.hash will get you the hash-value of a url.

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

2 Comments

can i user it like this $("#"+location.hash == "#overview").css({"display":"none"})
That would be if(location.hash=='#overview') $('#overview').hide();
0

use window.location. On the onLoad event of the page, parse everything after "#" in window.location.toString(), and act accordingly.

3 Comments

Or use location.hash as peirix pointed out. I didn't know about it. It is cross-browser?
Try it yourself in the browsers you are targeting: w3schools.com/HTMLDOM/prop_loc_hash.asp
Yeah, it's been in IE since v.4, FF since v.1 and Opera since v.9...should be safe (:

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.