Solved

jquery update URL

Posted on 2011-03-23
2
362 Views
Last Modified: 2012-05-11
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?

E.g.
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.

Thanks
0
Comment
Question by:dev09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 35197307
If the URL you are refering to is the URL of page
then
<a href="javascript:changeURL()">

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


0
 
LVL 13

Assisted Solution

by:darren-w-
darren-w- earned 250 total points
ID: 35197688
Jquery:

 
<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <style type="text/css">
        </style>
        <script type='text/javascript'>
            $(function(){                 
                $("a").click(function(){
                    $(this).attr("href",$(this).attr("href")+"/2")
                })
            });

        </script>
    </head>
    <body>
        <a href="#">location</a>
    </body>
</html>

Open in new window


this will though keep appending to the url on subsequent clicks, but does the same as above
0

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question