Working with Pop Ups and Browser Windows in JavaScript
This series of articles mainly concentrates on working with browser windows and sub-windows in JavaScript. You can reuse these scripts to inject into server side controls easily (especially in .NET and Java).
Working with Pop Ups and Browser Windows in JavaScript - How to access the data available in the main window from within a pop up window and vice versa using JavaScript (Page 4 of 5 )
The code for the main window would be as follows:
<html> <head> <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"> <script id="clientEventHandlersJS" language="javascript"> <!-- // global variable for subwindow reference var w; function openNewWindow( ) { if (!w || w.closed) { w = window.open("","NewWindow","status,height=200,width=300"); // delay writing until window exists in IE/Windows setTimeout("openNewWindow( )", 50); } elseif (w.focus) { // window is already open and focusable, so bring it to the front w.focus( ); } // write HTML to new window document w.location.href="HTMLPage7_1.htm"; w.document.close( ); // close layout stream }
function Button1_onclick() { openNewWindow(); }
function Button2_onclick() { document.all.txtParentName.value = w.document.getElementById ("txtName").value; }