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

Q324 When attempting to change the location of a frame in a window that has just been opened it sometimes fails with window.frame has no properties, why?

You are here: irt.org | FAQ | JavaScript | Frame | Q324 [ previous next ]

What has happened, is that the window or the frame has not yet been created. You can work around this in two ways. Either introduce a delay when changing the location using the setTimeout method to change the location after, say, 1 second. Or use a derivative of the Re-directing access within Frames article.

First when opening the window that holds the frameset, pass an encoded url, i.e. apage.html:

<SCRIPT LANGUAGE="JavaScript"><!--
function newWindow() {
    filename = 'frame.html' + '?' + escape('apage.html');
    myRemote=window.open(fileName,'windowName');
    myRemote.location.href = fileName;
    if (myRemote.opener == null) msgWindow.opener = window;
}
//--></SCRIPT>

And then in the frame.html frameset:

<HTML>
<SCRIPT LANGUAGE="JavaScript"><!--
document.write('<FRAMESET COLS="20%,*">');
document.write('<FRAME SRC="header.html" NAME="header">');
document.write('<FRAME SRC="' + (location.search ? unescape(location.search.substring(1)):'main.html') + '" NAME="main">');
document.write('<\/FRAMESET>');
//--></SCRIPT>
</HTML>

©2018 Martin Webb