An Example Image Gallery with Chrys`s Approach to ACP
An Example Image Gallery with Chrys`s Approach to ACP (Page 1 of 4 )
Image Gallery with the Document Phase of Chrys’s Approach
Assume that there is a session of three pages. The first page has text, the second page has text and the third page has an image gallery related to the two previous pages. For simplicity, let us have three images in the gallery. We shall download the first image with the first page; this image will not be displayed. We download the second image with the second page; this second image will not be displayed. We download the third image with the third page; this image will not be displayed immediately as it is downloaded.
In the third page's gallery, the first image downloaded will be displayed first, the second image downloaded will be displayed second and the third image downloaded will be displayed third. These images will be displayed on the same spot (area) of the third page. ACP is involved in the fact that the first two images and even the third are downloaded in advance.
Any good browser should cache images as soon as they have been downloaded. When the user arrives at the third page and asks for an image, it will be taken from the browser’s cache and not from the server.
As soon as you open the third page, the first image should be seen.
The Code for the First Page
This is the code for the first page:
This is the First page.<br />
<button type = "button" onclick="loadSecondPage()">Load Second Page</button>
//Here is the Ajax Code Segment. Same as in part V.
var pageTwo = document.open();
In this simple code, you have an HTML document. You have a HEAD element, which is empty, and a BODY element. The first line in the BODY element is text, which says that you are at the first page. This is followed by a line break element. Next you have a button; when this button is clicked, the second page is loaded.
Remember, in the description, we said that there are three images. All of the images will be displayed in the third page. One is downloaded in the first page, the other is downloaded in the second page and the third is downloaded in the third page. After the button mentioned above in the BODY element, you have the image tag for the first image. At this position, the first image is downloaded.
The image has an ID whose value is “I0.” We shall see the use of this ID on the third page. The value of the CSS display property for the image is “none.” In this way, the image will be at that position, but it will not occupy space and will not be seen. It is good to put the tag for the image below all the visible elements of the page. In this way, while the user is reading the page, the image will be downloaded.
After the Ajax code segment, you have the function to load the second page. The purpose of the three lines of this function should now be obvious.