jquery update URL

Hey guys,

Is it possible to update a URL with jQuery after a link is clicked on?

I have a content scroller in my web page that moves to different parts of the content, from navigation links (no page refresh) Can i update to the URL to have make a permalink to that exact part?

Before click:  URL:  http://www.test.com/
After click:     URL:  http://www.test.com/2

So that if anyone loads the /2 address it will load the 2nd part of the content scroller.

Who is Participating?
Gurvinder Pal SinghConnect With a Mentor Commented:
If the URL you are refering to is the URL of page
<a href="javascript:changeURL()">

function changeURL()
   location.href = location.href + "/2";

darren-w-Connect With a Mentor Commented:

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <style type="text/css">
        <script type='text/javascript'>

        <a href="#">location</a>

Open in new window

this will though keep appending to the url on subsequent clicks, but does the same as above
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.