CGI
view release on metacpan or search on metacpan
features.
See the section on debugging for more details.
# GENERATING DYNAMIC DOCUMENTS
Most of CGI.pm's functions deal with creating documents on the fly. Generally
you will produce the HTTP header first, followed by the document itself. CGI.pm
provides functions for generating HTTP headers of various types.
Each of these functions produces a fragment of HTTP which you can print out
directly so that it is processed by the browser, appended to a string, or saved
to a file for later use.
## Creating a standard http header
Normally the first thing you will do in any CGI script is print out an HTTP
header. This tells the browser what type of document to expect, and gives other
optional information, such as the language, expiration date, and whether to
cache the document. The header can also be manipulated for special purposes,
such as server push and pay per view pages.
lib/CGI.pod view on Meta::CPAN
See the section on debugging for more details.
=back
=head1 GENERATING DYNAMIC DOCUMENTS
Most of CGI.pm's functions deal with creating documents on the fly. Generally
you will produce the HTTP header first, followed by the document itself. CGI.pm
provides functions for generating HTTP headers of various types.
Each of these functions produces a fragment of HTTP which you can print out
directly so that it is processed by the browser, appended to a string, or saved
to a file for later use.
=head2 Creating a standard http header
Normally the first thing you will do in any CGI script is print out an HTTP
header. This tells the browser what type of document to expect, and gives other
optional information, such as the language, expiration date, and whether to
cache the document. The header can also be manipulated for special purposes,
such as server push and pay per view pages.
lib/CGI/HTML/Functions.pod view on Meta::CPAN
B<-onMouseOut> and B<-onUnload> parameters are used to add JavaScript calls to
your pages. B<-script> should point to a block of text containing JavaScript
function definitions. This block will be placed within a <script> block inside
the HTML (not HTTP) header. The block is placed in the header in order to give
your page a fighting chance of having all its JavaScript functions in place even
if the user presses the stop button before the page has loaded completely. CGI.pm
attempts to format the script in such a way that JavaScript-naive browsers will
not choke on the code: unfortunately there are some browsers that get confused by
it nevertheless.
The B<-onLoad> and B<-onUnload> parameters point to fragments of JavaScript code
to execute when the page is respectively opened and closed by the browser.
Usually these parameters are calls to functions defined in the B<-script> field:
$q = CGI->new;
print header;
$JSCRIPT = <<END;
// Ask a silly question
function riddle_me_this() {
var r = prompt(
"What walks on four legs in the morning, " +
lib/CGI/HTML/Functions.pod view on Meta::CPAN
=head2 Ending the Html document:
print $q->end_html;
This ends an HTML document by printing the </body></html> tags.
=head1 CREATING STANDARD HTML ELEMENTS:
CGI.pm defines general HTML shortcut methods for many HTML tags. HTML shortcuts are named after a single
HTML element and return a fragment of HTML text. Example:
print $q->blockquote(
"Many years ago on the island of",
$q->a({href=>"http://crete.org/"},"Crete"),
"there lived a Minotaur named",
$q->strong("Fred."),
),
$q->hr;
This results in the following HTML code (extra newlines have been
lib/CGI/HTML/Functions.pod view on Meta::CPAN
print button(-name=>'button_name',
-value=>'user visible label',
-onClick=>"do_something()");
-or-
print button('button_name',"user visible value","do_something()");
button() produces an C<< <input> >> tag with C<type="button">. When it's
pressed the fragment of JavaScript code pointed to by the B<-onClick> parameter
will be executed.
=head1 WORKING WITH FRAMES
It's possible for CGI.pm scripts to write into several browser panels
and windows using the HTML 4 frame mechanism. There are three
techniques for defining new frames programmatically:
=over 4
( run in 0.823 second using v1.01-cache-2.11-cpan-364913b4093 )