Non-Display Image Silently Causes CGI Program to Run  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Javascript
Written by Adi Bach   
Monday, 02 April 2007

{mos_sb_discuss:23}

JavaScript can be used to create an image object (an area in computer memory that holds the details the browser will need to display an image). No HTML code is needed.



CGI programs can be launched with JavaScript by telling the browser to fill the image object with information, and giving the browser the URL of the CGI program as the source for the image information it is to use.
 
This is an exciting method used by savvy programmers to run CGI programs in the background.

The program can run when a page loads or when certain other events happen, such as which link was clicked. The program can run more than once, as often as needed, in fact.

Some implementation ideas:
   1.The program can log details of certain activities, like which link was clicked, to continue using the previous example.

      The length of time the user spent on the page can be logged. Right-clicks can be logged, along with information about where the cursor was when the mouse was right-clicked.

      Numerous activities can be detected and logged.

   2.The program can set and read cookies — which JavaScript can do by itself but, unlike JavaScript, a CGI program can upate databases.

   3.The programs can update databases with items of information like browser used, IP address, and prior visit history (if cookies are used).

Before the CGI script ends its run, it sends the content of an image file to the browser. This satisfies the browser's request.

Note: The introduction article, "Running a CGI Program On Page Load," contains numerous examples for automatically running a script when a page loads and has links to several different methods of implementing those features for your web site.
Page Events Automatically Run a CGI Program

To cause a page event to automatically run a CGI program, JavaScript is used to detect the event and then launch the program.

The following JavaScript detects a page load event (when a page completes loading) and sends the URL of itself to the CGI program.

Read more


User reviews

There are no user reviews for this item.

Add new review




Powered by jReviews

Last Updated ( Wednesday, 04 July 2007 )
 
< Prev   Next >