how to call a java script function in a child window from the pare

F

Frank H. Shaw

how to call a java script function in a child window from the parent?

The function in the child window is setform();

Here's the script in the child:

<script id="setformscript">
function setform(){
this.document.forms[0].comments.value="Please BACKORDER for me: U.S. DIVERS
COZUMEL SEABREEZE SET";
}
</script>


And the parent:

<script language="JavaScript">
function newWindow(){
win2 = window.open("order.htm","win2");
}
function test(){
if (window.win2)
alert('mywindow exists');
else
alert('mywindow does not exist');
}
window.win2.document.GetElementById.setformscript = "setform();";
</script>

The purpose is to set a form element by remote from the parent window. The
parameter that needs to be applied is on the child window. I'm wrestling
with the text necessary to effect the call, I think...

Please let me know if you have any info to offer,
thanks,
Dan
 
S

Steve Easton

call the function with an onload event in the opening body tag of the child.

<body onload="setform()">

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
F

Frank H. Shaw

Well, the problem is...

The htm in the parent window (knows the proper setting for a form) and needs
to issue that setting to a form in the child window, effecting an alteration
of a text value. The child window displays a contact form that is to be
customized by the parent window (the product htm) to represent a request for
a instock notification.

I was trying to from the parent window script>
winname.form-name.form-element-name.value = "backordered";</script>

Word of mouth (unverified source) told me parent to child form alteration is
impossible for security reasons.

So I'm trying to put
<script>
function wateva(){
winname.form-name.form-element-name.value = "backordered";
}
</script>
on the child and then call wateva() from the parent. My best attempt
resulted in a permission denied...

So, What now...?

Thanks,
Dan


Steve Easton said:
call the function with an onload event in the opening body tag of the child.

<body onload="setform()">

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer

Frank H. Shaw said:
how to call a java script function in a child window from the parent?

The function in the child window is setform();

Here's the script in the child:

<script id="setformscript">
function setform(){
this.document.forms[0].comments.value="Please BACKORDER for me: U.S. DIVERS
COZUMEL SEABREEZE SET";
}
</script>


And the parent:

<script language="JavaScript">
function newWindow(){
win2 = window.open("order.htm","win2");
}
function test(){
if (window.win2)
alert('mywindow exists');
else
alert('mywindow does not exist');
}
window.win2.document.GetElementById.setformscript = "setform();";
</script>

The purpose is to set a form element by remote from the parent window. The
parameter that needs to be applied is on the child window. I'm wrestling
with the text necessary to effect the call, I think...

Please let me know if you have any info to offer,
thanks,
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top