In this article I will show you how browsers respond to Active Client Pages. In particular, we will focus on the question of whether different browsers respond to all the features of Active Client Pages as they should. Recall that browsers do not implement all the features in the HTML, JavaScript and DOM specifications. So we need to ask this question.
How Browsers Respond to Active Client Pages - Technical Description of the Simple Example (Page 4 of 4 )
Each window or document, which would produce another window or document, has a button for that purpose. So there is a corresponding function for that purpose in such a page. The window at the first level that can produce one of two windows has two buttons for that, and two corresponding functions. For simplicity, each window or document downloads the content of its next page, which may be a window or a document that it would produce. The window at level one that has to produce two windows downloads the contents of the two pages (windows).
The store is simple. It has just the following variable and assigned value (it has just the following statement):
var storeVarMaster = "It worked!";
The third level has one window and two documents. The parent of the one window is different from the parent of the two documents. This one window has a button which, when clicked, would display the value of the above variable. That is, the alert box would display "It worked!"
To achieve this, there is a Backward Propagation Code in each window in the chain from the master page to the window at level 3 (the master page is the first window). This code is used to retrieve the value of the variable in the master page.
The second document at the third level is produced by the first document in that level, that is produced by the window of page2-2. This second document has a button that, when clicked, would display the value of a JavaScript variable in the window (page2-2). This variable is in the window of page2_2 and its assignment is:
var storeVar2_2 = "I am 2_2";
So the alert() box will show "I am 2_2".
In ACP I call a window or a document a page. In this example, each page downloads the next page or pages of the next level that it is supposed to produce in advance.
The window at the fourth level produced by Doc1 also has a button. When you click this button, the value of a JavaScript variable in Doc1 is displayed. The variable in Doc1 and its assignment is:
var var3_1 = "I am 3_1";
So the alert box displays "I am 3_1".
The statement in the fourth window that does this is:
alert(window.opener.var3_1);
Note the expression "window.opener.var3_1". Even though the execution of this statement was successful, today, it is good to avoid accessing any variable or function in the document phase from outside the document phase; I will explain this later.
We can take a break here. In the next part of the series we look at the code of the simple example, as this will help us to appreciate the way that browsers respond to ACP.
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.