-1

For example, When you click a tag which is linked to an ID value in the same page, URL is changed like this : index.html#content04. But, since I use scroll event that shows headers of each sector when mouse wheel is scrolled down, I want to make the URL default just like index.html to hide all the headers of each section so that I can see them only when I scroll down. How do I make a script for this?

URL : index.html#content04. -> index.html // when refreshed

imbondbaby
  • 6,253
  • 3
  • 18
  • 53
user3444463
  • 59
  • 1
  • 6
  • Are you using a javascript library that provides a means to scroll to an element using Javascript? If so, call that method in the onclick handler for the links in question, like `SomeTag`. Your target would look like: `SomeTag Target`. – J.D. Pace Jul 02 '14 at 04:03
  • possible duplicate of [Is it possible to have the url change while you scroll down a single page](http://stackoverflow.com/questions/6146560/is-it-possible-to-have-the-url-change-while-you-scroll-down-a-single-page) – X-Istence Jul 02 '14 at 04:49

3 Answers3

0

You may want to look into the location object:

if (location.hash) {
    location.href = location.href.substr(0, location.href.indexOf('#'));
}
Igor
  • 31,955
  • 14
  • 75
  • 111
0

You should be able to do this with suggestion on this answer: https://stackoverflow.com/a/16337643/1450348?stw=2

Community
  • 1
  • 1
manman
  • 4,346
  • 3
  • 26
  • 41
0

you can use preventdefault() Ex. http://api.jquery.com/event.preventdefault/ or use return false; as @J.D. Pace mentioned

mry
  • 304
  • 1
  • 11