Professional Web Applications Themes

onunload is a great function but it generates popups! - PHP Development

Does anyone know a way to use the htm <body onunload=foo()> function to execute a php script without creating another window (popup). This has some real applications for tracking visitors and getting accepted by the google monster. I am simply trying to write (append) a file with information on exit from my web site. Seems like that should not be a big deal....

  1. #1

    Default onunload is a great function but it generates popups!

    Does anyone know a way to use the htm <body onunload=foo()> function
    to execute a php script without creating another window (popup). This
    has some real applications for tracking visitors and getting accepted
    by the google monster.

    I am simply trying to write (append) a file with information on exit
    from my web site. Seems like that should not be a big deal.


    Martin Guest

  2. #2

    Default Re: onunload is a great function but it generates popups!

    "Martin" wrote:
     

    Change the offsite links so that they point to a local redirection script.
    For example, change <A href="http://site2.example.com/"> into something like
    <A href="/redirect.php?to=http%3A//site2.example.com/">.

    In the redirect.php script, do whatever you have to, and then issue a
    redirect header like this:

    <?php header("Location: " . $_GET['to']); ?>

    More info -> <http://php.net/header>

    --
    phil [dot] ronan virgin [dot] net
    http://vzone.virgin.net/phil.ronan/


    Philip Guest

  3. #3

    Default Re: onunload is a great function but it generates popups!

    Martin wrote:
     

    Hmm intersting not seen that one b4.

    You could set the src of an img or an iframe. Of course you'd need to give
    the page enough time to send the request before allowing it to go
    elsewhere.

    I'd be interested to hear how you solve this one.

    C.
    Colin Guest

  4. #4

    Default Re: onunload is a great function but it generates popups!

    onunload is client side whereas PHP executes on the server. There is no
    way for PHP to know when a browser has left a certain page or closed the
    window. Most forums keep track of the last time a client was active then
    display a list of members active within a "reasonable" amount of time
    (normally 30 minutes).

    HTH,
    Laie Techie


    Lāʻie Guest

Similar Threads

  1. Why no onLoad or onUnload on _root?
    By Carl Fink webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: January 28th, 08:01 PM
  2. There are ONUNLOAD limits?
    By Rafael in forum Informix
    Replies: 2
    Last Post: January 10th, 09:18 PM
  3. popups advertising to stop popups
    By Bruce Chambers in forum Windows Setup, Administration & Security
    Replies: 1
    Last Post: July 12th, 09:36 PM
  4. Brown popups offering to give programs to block popups
    By George A Windsor in forum Windows Setup, Administration & Security
    Replies: 1
    Last Post: July 10th, 06:35 PM
  5. onunload event
    By RobGT in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 10th, 01:17 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139