Welcome to the fourth part of a five-part series that shows how browsers respond to Active Client Pages. In this part, we complete the code for the simple example to be used to test the response of browsers to Active Client Pages, and then we look at the features in the example that we shall use to assess the browsers.
Testing Browser Response to Active Client Pages - Level 4 (Page 2 of 4 )
There is only one window at level 4. This window is produced by Doc1, which is the second document in a window at level 3. This window at level 4 is produced when you click a button in Doc1. The content of this window is in a file called sendWinPge4Str.pl in the server. This is the content of the file:
$returnStr = qq{
<html>
<head>
<script type="text/javascript">
function showValueIn3_1()
{
alert(window.opener.var3_1);
}
</script>
</head>
<body>
This is page 4 win<br />
<button type="button" onclick="showValueIn3_1()">Show the Value in Page 3_1</button>
</body>
</html>
};
print $returnStr;
There are two Perl statements in the file, as in the others. The quote operator has an HTML document. Remember that each window in this example has at least one HTML document. There is actually only one window in this example that has more than one HTML document; it has two HTML documents. The window here has one HTML document.
The HEAD element of the window here has a JavaScript. This JavaScript has one function, called showValueIn3_1(). There is a button in the BODY element. When this button is clicked, the showValueIn3_1() function is called. This function has an alert() statement. The alert() statement displays the value of the var3_1 variable residing in Doc1. This value is "I am 3_1." The argument of the alert function is:
window.opener.var3_1
In this expression, window represents the present window. Opener is a reference to the window that opened the present window. Var3_1 is a JavaScript variable in the opener window. When the showValueIn3_1() function is called, the value of the var3_1 variable is displayed.
Again, this sounds good; however, for ACP programming today, I do not advise you to make calls from the document phase into the window phase and vice-versa. I will explain why in the next part of the series.
Let us look at what is in the BODY element. All you have in the BODY element is some text, a line break element and a button. When this button is clicked, the showValueIn3_1() function is called.
That finishes the explanation of the complete code. I described the Simple Example in part 1 of the series; I have used part 2 and 3 to explain the complete code. Now that you understand the example including its coding, you are in a good position for a technical assessment of the response of browsers to ACP.