Forum Moderators: open

Message Too Old, No Replies

Using anchors with Javascript

using an anchor passed from another page

         

tomAtRPI

3:59 pm on Aug 29, 2004 (gmt 0)



What i need to do is call an anchor on another page. When this page loads I need that anchor that I called to be fed into a javascript function that gets called onLoad. Basically All the sections are invisible until called, and I need to be able to display whichever section (called using anchors) is requested.

So my question is, how do I feed the anchor that is being passed to the page into my javascript, as a variable?

Bernard Marx

4:08 pm on Aug 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You want the location's hash property. It includes the #, so

req = location.hash.substring(1)

Perhaps you could use the search property instead, so the page won't automatically scroll down to the element with that id.

<a href="page.htm?boo">
....
req = location.search.substring(1)