You are here: irt.org | FAQ | JavaScript | Form | 3.1 | Q165 [ previous next ]
If one window opens another:
<script language="JavaScript"><!-- function newWindow(file,window) { msgWindow=open(file,window,'resizable=no,width=200,height=200'); if (msgWindow.opener == null) msgWindow.opener = self; } //--></script> <form> <input type="button" value="Open New Window" onClick="newWindow('a.html','window2')"> </form>
Then to access a variable in the new window from the original window:
var myVar = msgWindow.myVar;
To access a variable in the original window from the new window:
var myVar = opener.myVar;
To access the contents of a form field in new window from the original window:
var myVar = msgWindow.document.formName.formFieldName.value;
To access the contents of a form field in the original window from the new window:
var myVar = opener.document.formName.formFieldName.value;
To access the contents of a form field in the original window from a frame in the new window:
var myVar = top.opener.document.formName.formFieldName.value;