Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: window.opener in Netscape


Message #1 by "John Hollis" <highnightflyer@y...> on Sat, 10 Aug 2002 12:28:35
I removed Netscape, trying to upgrade but gave up..., so I can't test much. 
Try writing:
window.opener.document.title
instead of the input box value and build up. It may be the value is being 
referred to incorrectly, although I see nothing wrong. Try the full syntax:
window.opener.document.forms["myForm"].elemnts["oneVal"].value;
What version of NN is this, I'll try to find a machine with it on.

Joe


>From: "John Hollis" <johnhollis@h...>
>Reply-To: "javascript" <javascript@p...>
>To: "javascript" <javascript@p...>
>Subject: [javascript] Re: window.opener in Netscape
>Date: Sun, 11 Aug 2002 22:49:54
>
> > ----- Original Message -----
>From: "John Hollis" <highnightflyer@y...>
>To: "javascript" <javascript@p...>
>Sent: Saturday, August 10, 2002 12:28 PM
>Subject: [javascript] window.opener in Netscape
>
>
> > Hello, I'm trying to pass a value, held by a variable, from a parent
> > window to a child window using the window.opener method which
> > works in IE but does not in Netscape.
> > A hyperlink calls a function which opens a new window and passes
>a
> > value to that function.In order to make that value global it is
>assigned
> > to a hidden form. The new window simply displays that value using
> > the code:
> > window.opener.formName.inputName.value
> >
> > this works fine in IE but NN displays 'undefined', and it needs to
>work
> > in netscape, this seems so simple but my code doesnot function in
> > NN.
> >
> > here is the code of the parent window:
> >
> >
> > function newWindow(varNum)
> > {
> > var varNum;
> > document.myForm.oneVal.value = varNum;
> >
> > var newWin;
> > newWin 
> > window.open("child.html","window","width=200,height=200");
> > newWin.focus;
> > }
> > var passVal = document.myForm.oneVal.value;
> > </script>
> > </head>
> > <body>
> > <a href="javascript:newWindow(4)">Click Here for 4</a><br>
> > <a href="javascript:newWindow(2)">Click Here for 2</a>
> > <form name="myForm">
> > <input type="hidden" name="oneVal" value="">
> > </form>
> >
> > and here is the code for the child window:
> >
> > <script language="javascript" type="text/javascript">
> > var current = window.opener.document.myForm.oneVal.value;
> > </script>
> > <body>
> > <script language="javascript">document.write(current)</script>
> >
> > Thanks for any suggestions as to why this does not work in
>Netscape
>
>Probably because you're using the pseudo-protocol of JavaScript
>instead of
>the correct method of opening the window using a function attached
>to the
>onclick attribute of the 'a' tag and returning false to cancel the actual
>hyperlinking.
>
>Joe
>
>
>Thanks Joe- I tried invoking the function using the onClick event
>handler and again it works fine in IE however not in NN, same
>problem, it opens the window and displays 'undefined'. Any
>thoughts?
>Here is my updated code for the parent window:
>
>
>function newWindow(varNum)
>	{
>var varNum;
>document.myForm.oneVal.value = varNum;
>	var newWin;
>newWin 
>window.open("child.html","window","width=200,height=200");
>			newWin.focus;
>			return false;
>			}
></script>
>	</head>
><body>
>	<a href="" name="child" onClick="newWindow(4)">Click Here for
>4</a><br>
>	<a href="" name="child" onClick="newWindow(2)">Click Here for
>2</a>
>
><form name="myForm">
>	<input type="hidden" name="oneVal" value="">
>	</form>
></body>
></html>
>
>
>---
>
>Improve your web design skills with these new books from Glasshaus.
>
>Usable Web Menus
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
>r-20




_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


  Return to Index