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

Re: how to call a java script function in a child window from the pare by Steve

Steve
Wed Jun 01 15:42:34 CDT 2005

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" <FrankHShaw@discussions.microsoft.com> wrote in message
news:601CC9B6-A300-4D58-A00C-97A33CCD045D@microsoft.com...
> 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



Re: how to call a java script function in a child window from the by FrankHShaw

FrankHShaw
Wed Jun 01 21:02:26 CDT 2005

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" wrote:

> 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" <FrankHShaw@discussions.microsoft.com> wrote in message
> news:601CC9B6-A300-4D58-A00C-97A33CCD045D@microsoft.com...
> > 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
>
>
>