Principles of Active Client Pages: the Script Approach
(Page 1 of 4 )
In this part of the series, I give the principles of the Script Approach to Active Client Pages. I am the one who came up with these principles to suit the advantages I mentioned in the previous part of the series. In order for you to understand the Script Approach, I will have to explain the simple example we saw previously. This article is the second part of a three-part series.
Explanation of the Simple Example
To have a frameset, you need a normal HTML document. Then, instead of having the BODY element in the document, you have but the frameset tags. The frameset tags can have several frames (tags) within them. Each frame takes an HTML document.
In our case we have only one frame. Note how the frame and frameset ("100%,*">) have been declared. The source file for our single frame is myChild.htm (see source code on the next page). The name of the frame is myChild.
The JavaScript for the frameset document has an array and two variables. The array is created in the script of the frameset document. The first element of this array has all the content (HTML elements) of the first page, except the <html> and </html> tags and some small JavaScript. See how the HTML elements forming the contents have been assigned as a string. This is one of the important factors of the Script Approach; the page contents are handled as strings.
The next variable in the frameset script is pInx. It is initialized to zero. This zero refers to the first element in the array. The array elements are to hold pages in string form. Index zero for the array is for the first page, index 1 is for the second page, index 2 for the third and so on. To display a page, you simply send the string value of the corresponding array element to the frame.
For this example, the frameset document is our master, which has the store. The store is the array. Generally, the store is a combination of variables, object properties and arrays. As the pages are downloaded, they are stored as long strings in the array.
Note that our example makes use of only the first and second elements of the array, since we have just two pages. You cannot store data in the frame document, since you always have to be changing its content.
Next: Source Code >>
More JavaScript Articles
More By Chrysanthus Forcha