Curren Web Browser Location

Discussion in 'JavaScript' started by redhits, Mar 6, 2008.

  1. #1
    Is it possible to get the current browser location with JavaScript?!
     
    redhits, Mar 6, 2008 IP
  2. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #2
    location=url?

    If yes than try this

    var url = window.location.href;

    var url has url of the page.
     
    greatlogix, Mar 6, 2008 IP
  3. redhits

    redhits Notable Member

    Messages:
    3,023
    Likes Received:
    277
    Best Answers:
    0
    Trophy Points:
    255
    #3
    Hmm , and now a big questions , how i can post this into an "input type=hidden" field!?
     
    redhits, Mar 7, 2008 IP
  4. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    An even bigger question is, why would you need to? The server-side counterpart can find out the URL of the submitting page by looking at the HTTP_REFERER variable.

    But if you really need to, do this:

    
    window.onload = function() { document.forms[0].[I]hiddenFieldName[/I].value = location.href; };
    
    Code (markup):
     
    vpguy, Mar 7, 2008 IP
  5. redhits

    redhits Notable Member

    Messages:
    3,023
    Likes Received:
    277
    Best Answers:
    0
    Trophy Points:
    255
    #5
    Wow, nice idea, never thought of it
     
    redhits, Mar 7, 2008 IP