JavaScript to take value from url

Discussion in 'JavaScript' started by KingCobra, Feb 29, 2012.

  1. #1
    page01.html

    In my page01.html file there is a link code: <a href="page02.html?name=abc">go to page 2 </a>


    page02.html

    I need a JavaScript code in this page that will take the value of 'name' from the url when a visitor comes from clicking the above link from page01.html.


    Thanks
     
    KingCobra, Feb 29, 2012 IP
  2. Remajahost

    Remajahost Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Remajahost, Feb 29, 2012 IP
  3. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #3
    This should work:
    
    var url = location.href;
    var parts = url.split('=');
    var name = parts[1];
    
    Code (markup):
     
    Arttu, Mar 1, 2012 IP
  4. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #4
    JohnnySchultz, Mar 6, 2012 IP