Get Url Change

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baburk
    New Member
    • Oct 2006
    • 111

    Get Url Change

    Hi,

    I had wrote this script to get the changed URL.

    I called this in <body onunload = "GetUrl();" >

    The problem is that it gives the old url but not the changed url.

    ie the function url is http://localhost:4241/WorkedOut/Default.aspx
    when i changed to www.google.com it gives http://localhost:4241/WorkedOut/Default.aspx but not www.google.com

    [CODE=javascript] function GetUrl()
    {
    var href = document.locati on.href;
    alert(href);

    alert(document. location.host);
    }
    [/CODE]
    Thanks in advance
    Last edited by acoder; May 12 '08, 12:01 PM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You can't get the new URL especially if it's from a different domain.

    What do you need this information for?

    Comment

    • baburk
      New Member
      • Oct 2006
      • 111

      #3
      Originally posted by acoder
      You can't get the new URL especially if it's from a different domain.

      What do you need this information for?
      I want this for, if the user enters different url i wants to end the session.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Use a timeout instead. After a period of inactivity, terminate the session on the server.

        Comment

        • baburk
          New Member
          • Oct 2006
          • 111

          #5
          Originally posted by acoder
          Use a timeout instead. After a period of inactivity, terminate the session on the server.

          But I wants, it should be called suddenly when the user gives another url.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Why? What difference would it make?

            Say the user goes to another site and then comes back within a minute. Would you want them signed out?

            Comment

            Working...