A Multiple Page Image Gallery with Active Client Pages
You can have a web page which has pictures. This page may have links to other pages that have pictures. The linked pages may also have links to pages that have pictures, and so on. In this second part of a two-part series I show you how to make the pictures in all these pages display quickly at the browser, when the user clicks a button. Of course, we are going to use ACP techniques to solve the problem. Only the first picture of the first page may be displayed slowly.
A Multiple Page Image Gallery with Active Client Pages - The Three Pages (Page 4 of 4 )
The contents of these three pages are in Perl files. There are three corresponding Perl files for these pages. The names of these files are: dept0.pl, dept1.pl and dept2.pl. I will explain only the content of the first one. The other two are similar. This is the content of the dept0.pl file:
$returnStr = qq{
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
There are just two Perl statements in this file. The statements are:
$returnStr = qq{};
and
print $returnStr;
You have the quoting operator, qq{}. Whatever is in the {} brackets is considered to be a string. The {} brackets handle the HTML content you would have for an HTML document. So you do not have to escape anything. The second Perl statement returns the string of the qq{} operator, when the file is called by the Ajax function in the master page.
You can now read through the contents of the file. The logic of what is inside the qq{} operator is similar to what we have in the master page, so I will not explain it.
You can download the complete code for this part of the series from here:
Remember that I use a personal web server for the example. To test it, create the directories as mentioned above, unzip and copy the files to their respective directories. Start your personal web server, open your browser window, type http://localhost/example.htm in the address bar and click Go.
The directories and their different files are as follows:
root
example.htm
cgi-bin
dept0.pl
dept1.pl
dept2.pl
masterImages
m0.gif
m1.gif
m2.gif
m3.gif
m4.gif
department0Images
d0_0.gif
d0_1.gif
d0_2.gif
d0_3.gif
d0_4.gif
department1Images
D1_0.gif
D1_1.gif
D1_2.gif
D1_3.gif
D1_4.gif
department2Images
D2_0.gif
D2_1.gif
D2_2.gif
D2_3.gif
D2_4.gif
Response from Browsers
Internet Explorer 6 handles the example well. Mozilla Firefox 2 handles it reasonably. Netscape 8 could not handle the example. Opera 9 handled it reasonably. Safari 3 could not handle the example.
However, note that for the single page case in the previous part of the series, the example worked with all of the above browsers.
Well, we have come to the end of the series. You have learned how to use ACP to produce a fast operating image gallery. I hope you appreciated it.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.