Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1307 How do I access variable values and form field values across windows where the popup window has frames?

You are here: irt.org | FAQ | JavaScript | Form | 3.1 | Q1307 [ previous next ]

If one window opens another:

<script language="JavaScript"><!--
var msgWindow;

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 a frame in the new window:

var myVar = top.opener.myVar;

To access the contents of a form field in a frame in the new window from the original window:

var myVar = msgWindow.frameName.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;

Feedback on 'Q1307 How do I access variable values and form field values across windows where the popup window has frames?'

©2018 Martin Webb