highlight: Window Interactions
myWin = window.open(file_url,
= window.open("", "", "width=200,height=200");
//creates an empty 200xx200 window
Now the file name or URL is where the browser will look to find the new window to open as in the case of cwin just above. . However, if the file argument is left blank, " ", then the browser will create an empty window and give it the name supplied in the second argument - as in bwin example. And finally the first case will create a completely empty window. But you can fill it up with content like so:The next set of code of interest is what happens in the created window. Three things. First it steals its background color from the Main window. Second it finds the name of the Main window and prints it in a popup. Third it passes input from its window back to the Main Window. Not too shabby. Let see how in reverse order.
<INPUT TYPE="text" SIZE=25 onChange="self.opener.document.forms.entry.value = this.value">
works like "this" in Java and other languages, it refers to the
window being currently used. But self.opener refers to the window
that opened this one - the parent or Main window. document.forms refers
to the first form in the Main Window (this page, in fact). And entry.value
refers to the name of the inpout text field in this window. So jstagteam.htm
passes a value back to its calling Web page, this page. Now just think of
how this can be generalized. A user fills in a detail form - and then passes
the key fields for display back in the main window. the opportunities for
between page transfer of data are only limited by the lack of support for
HTML tag elements among the browsers.
explain thhe second feature, displaying from the 2nd window, the title of
the main window is actually easy to do. Just as before self.opener refers
back to the window that called or opened this one. document.title refers
to the Main window's title - and the alert() just packages it up
in a convenient browser popup message window.