0

Hi i am using scroll to method for ging to particular places on a place but the url name is always same. Can't i have different url endings. I mean url always ends with #. Can't i have #products or #about. I am using this code.please help me

<span><a href="#" id="start1"onclick="Effect.ScrollTo('about',{duration:1.0}); return false;"class="scroll"style="text-decoration:none;position:absolute;right:145px;top:30px;font-weight:bold;color:white;font-size:15px" onmouseover="big(this)" onmouseout="small(this)">ABOUT US</a></span>

1 Answers1

0

You can just use the History API to push a URL change to the page when the user clicks on the link (https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history), for example using jQuery:

$("#start1").click(function(e){
    e.preventDefault();
    Effect.ScrollTo('about',{duration:1.0});
    history.pushState(null, null, '#about');
});

Or you could look into using a straight up hash link, e.g. putting href="#about" into the anchor and preventing the hash jumping (How can I update window.location.hash without jumping the document?).

**EDIT

Heres a jsFiddle: https://jsfiddle.net/3uwkcebk/1/

Community
  • 1
  • 1
Tom
  • 330
  • 1
  • 3
  • 17