www.webdeveloper.com
Results 1 to 2 of 2

Thread: Getting url browser value before page change

  1. #1
    Join Date
    Oct 2007
    Posts
    4

    Question Getting url browser value before page change

    Hi, im working on a script that confirms if a visitor really want to leave the site. My skills at javascript arent good but i found a working script to do this.

    <script>

    window.onbeforeunload = function (evt) {
    var message = "*****************************************************\n\n
    TEXT
    \n\n*****************************************************";;
    if (typeof evt == "undefined") {
    evt = window.close;
    }
    if (evt) {
    evt.returnValue = message;
    }
    return message;
    }
    </script>

    Now my problem is that with every page change a confirmation is required, i need it to work only when the domain name change, maybe it can be done if the url browser bar value is passed to an IF operation, and if the value isnt the base domain it runs the above function.

    The problem is that i dunno how to do that value in JS.

    I have fixed it with a cookie check script in php, but its not the way i want it to work at end.

    Can anyone lend me a hand plz? Any other idea?

  2. #2
    Join Date
    Jan 2008
    Location
    Vanvouver
    Posts
    2
    You can use the code below to get the full URL:

    Code:
    <script language="javascript" type="text/javascript"> 
    document.write (document.location.href); 
    </script>
    And the following thread may help you on how to get part of the link:
    http://www.webmasterworld.com/forum91/2594.htm

    Thanks,

    ---------------------
    Catherine Sea
    http://www.dynamsoft.com
    http://www.scmsoftwareconfigurationmanagement.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles