Questions and Answers on Chrys`s Approach to Active Client Pages
In this eleventh part of a twelve-part series on active client pages (ACP), I give you more factors that gave rise to the Window Phase of Chrys’s Approach. We continue with the questions and answers more or less from where we left off last time.
Questions and Answers on Chrys`s Approach to Active Client Pages - How do you really give a window a name? (Page 5 of 5 )
You can give a window a name as you open the window. This is the syntax for the opened window:
window.open(URL,name,specs,replace)
The second parameter is used for this. You give the name in quotes.
After opening a window, you can still give it a name from the parent window. The following code opens a window and gives it a name:
myWindow = window.open();
myWindow.name = “windowOne”;
windowOne is the name of the window given.
Now, how do you give a name to the master or current window?
It is simple. In the JavaScript of the page, you should have the statement:
window.name = “master”;
where master is the name you have given to the current or master window.
Can you execute a JavaScript function in a different window?
You may not believe this, but the answer is yes. All you need is the reference to the window. In whatever window you are, you begin with the reference to the window; follow this reference with a dot, then the name of the function and its arguments in brackets. For example, assume that you have the following function in a particular window:
function myFn(param1, param2)
{
//statements of the function
}
Also assume that you are in a different window and you have the following variable, which holds the reference to this particular window.
var theRef;
In this different window, you can execute the function as follows:
theRef.myFn(arg1,arg2);
Wow, we have asked many questions and we have received the answers. Taking the definition of ACP into consideration, I think we have asked enough questions. We have got enough foundation to look at a simple example of the Window Phase of Chrys’s Approach. We shall look at this example in the next and last part of the series.
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.