IFRAME Tag Will Auto-Launch CGI Script
The "Running a CGI Program On Page Load" article has links to other methods of automatically and immediately launching CGI programs when a web page loads.
This article demonstrates one method and links to others that utilize the IFRAME tag to accomplish that objective.
If your website is much visited by those using older browser versions, consider using a different method of launching a CGI script when your web page loads.
Launching a Script with an IFRAME
The SRC of an IFRAME can be the URL of a CGI program. Before the program exits it sends the contents of a web page to the IFRAME. Alternatively, the program redirects the IFRAME to a different URL.
The IFRAME then displays that web page.
Here is an example IFRAME tag:
<iframe src="/cgi-bin/script.cgi" width="300" height="150"> </iframe>
The SRC of the IFRAME tag needs to be the URL of your CGI program.
The CGI program, before it exits, must either send a web page to the browser or redirect the browser to a web page at different URL. The browser then displays the web page in the IFRAME.
This is an example CGI script that sends a web page to the browser:
#!/usr/bin/perl use strict; # script can do other stuff here print "Content-type: text/html\n\n"; print <<PAGE; <html> <body> <p>Content</p> </body> </html> PAGE # end of script
Here is an example CGI script that redirects the browser to a different URL:
#!/usr/bin/perl use strict; # script can do other stuff here print "Location: https://www.willmaster.com/\n\n"; # end of script
Test your CGI program by typing its URL into your web browser. When it runs without errors, use its URL as the value of the SRC in an IFRAME tag.
Other Methods of Automatically Launching a CGI Script When a Web Page Loads
The "Running a CGI Program On Page Load" article has links to other methods of automatically and immediately launching CGI programs when a web page loads.
Will Bontrager