Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWebsite Automation

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

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

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC