Web Analytics Made Easy -
StatCounter Navigating away from a page - CodingForum

Announcement

Collapse
No announcement yet.

Navigating away from a page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Navigating away from a page

    Does anyone know how to launch a new page or execute anything on the server when a user navigates away from a page? I can catch the event using Javascript using:

    <body onunload="whatever()"> OR
    <body onbeforeunload="whatever()">

    But whenever I try to redirect to anther page it doesnt work...

    Ie:

    <body onunload="window.location=http://www.cnn.com">

  • #2
    Urm, this is nothing to do with php

    Comment


    • #3
      Hence the question: "Is there a way to do this on the server side ?"

      Ie: using PHP

      Comment


      • #4
        No, php is executed on the server, it has no idea what a window is or what the window is doing. It's never heard of a browser, so you can't execute something in php when the page is closed, unless you use javascript to call a php page. Which then becomes a javascript question

        Comment

        Working...
        X