Results 1 to 3 of 3

Thread: Call CGI script on leaving page?

  1. #1
    Join Date
    Jan 2003

    Call CGI script on leaving page?

    Does anyone know of a way to execute a CGI script when a user leaves a page? I would call it from onUnload with JavaScript, but that messes things up if the user clicked a link to leave the page--you know? they'll be redirected to the CGI script instead of the link they clicked.

    So is there any way to quickly call a simple CGI script when the user leaves the page (to log the time that they left), without interfering in the browser?

    Or if you know any alternate way to log what time the visitor left a page, you can tell me that!


  2. #2
    Join Date
    Nov 2002
    NY, USA
    Perhaps opening a small popup window on exit to the CGI script, then close the window afterward. However, there are still many ways that this could fail. It is never a good idea to rely on the user's machine to execute code the same way (if it executes at all).

  3. #3
    Join Date
    Jan 2003
    Yes I had considered the popup method...it seems the easiest way to redirect the user to two places at once, so to speak.
    The main problem with this is that I am on a free server (I will be moving up eventually, but I need to get going before I start paying), and there are a bunch of popup ads. I often use popup closers, and I'm sure other people will also (I even recommend some on the page because it's so annoying), so I would prefer not to rely on this.

    Since posting, I've gotten time to do a little research, and I've found that apparently Java (which I know nothing about; though I can read and manipulate the code since it's similar to C++) can open URL connections without actually displaying them. I am attempting to pursue this route--when the Java applet is stopped by the browser (i.e. the page stops being displayed), it opens a URL connection to a Perl script in the background, while leaving the user happily on their way to the site they clicked.

    Thank you for your reply, though!
    (And for your correction on one of my previous posts--always good to make sure people are getting the best)


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