Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 3.1 | Q1307 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.