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

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?

irt.org | Knowledge Base | JavaScript | Frame | Q324 [ previous next ]

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?

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>

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.