Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing fields in child window

Status
Not open for further replies.

ronsig

Programmer
May 24, 2001
54
IL
Hi!

I've tried accessing fields in a "child" window. Used something like this:
...
<script language=&quot;JavaScript&quot;>
function activate(target,targetApp)
{
var win='toolbar=0,directories=0,menubar=0,scrollbars=0;
var new_window = open(target,'',win);
new_window.document.frm.UserID.value = board.UserID.value;
new_window.document.frm.targetApp.value = targetApp;
new_window.focus();
}
</script>
...
Works like a charm in IE, but in Netscape (6) the script stops execution whnever I reach a line which tries to access fields in the child window (I also tried getting the values from the parent window by using 'opener' in an onload function in the child window, but that didn't work either!)

The most angering thing is that code very similar to this can be found in the javascript reference in the netscape home site! This is really getting me down!

A similar problem occurred when I tried accessing one frame from the other in the same page.
I used the following:
...
iframedoc = parent.frames[&quot;text&quot;].document;
var el = iframedoc.getElementById(&quot;board&quot;);// &quot;board&quot; is a form
el.innerHTML = htmlStr; // &quot;htmlStr&quot; was formatted beforehand
...
Again, IE happily obliged, while netscape stops execution!

So, can abyone help?
 
It may be because you didn't use document before you reference the field in the parent window:

Code:
new_window.document.frm.UserID.value = board.UserID.value;

...try changing it to this:

Code:
new_window.document.frm.UserID.value = document.board.UserID.value;
----------
function new Programmer(name,age)
{
this.name = name;
this.age = age;
}

var steven = new Programmer('Steven',11);
 
Nope, nothing!
I even tried just reading predefined values from the child window (using 'alert'). Again, IE showed them, netscape did not!

Could it be a problem with the browser settings? I have javascript enabled, is there something else which should be set?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top