Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: problem with my child window


Message #1 by "Alexander Bienz" <alex@v...> on Mon, 22 Apr 2002 17:51:22
This is a multi-part message in MIME format.

------=_NextPart_000_000F_01C1EAAF.45B43960
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

RE: [javascript] problem with my child windowAh that's brilliant yet simple,
I didn't realise that was possible, thanks, it works great now!

        Cheers,
                    Al.
  -----Original Message-----
  From: Debreceni, David [mailto:david_debreceni@r...]
  Sent: 22 April, 2002 19:11
  To: javascript
  Subject: [javascript] RE: problem with my child window


  I had read it somewhere before that for what ever reason this will always
cause the browser to fail.  We do something similar here and we call a
function on the opener to populate the box.  Hope that helps.

  <!-- Parent Window -->
  function myopen() {
    window.open('popup.htm','popup','width=250,height=250,status=Yes');
  }

  function addopt() {
          var myelm = document.form1.myoption;

          myelm.options[myelm.options.length] = new Option('test','test');
  }



  <!-- script in child window -->
  function addoption(){
    var odoc=opener.document.form1;
    odoc.myresult.value='result!';
          opener.addopt();

  self.close();
  }

  David Debreceni
  Senior Visual Basic/ASP Developer
   xxx-xxx-xxxx  x 1086



  -----Original Message-----
  From: Alexander Bienz [mailto:alex@v...]
  Sent: Monday, April 22, 2002 1:51 PM
  To: javascript
  Subject: [javascript] problem with my child window



  Hi there,

  I'm having trouble creating a new option in a parent window from my child
  window.

  Here's my code...

  Parent window

  <html>
  <head>
  <SCRIPT Language="Javascript">
  <!--
  function myopen(){
    window.open'popup.htm','popup','width=250,height=250,status=Yes');
  }
  //-->
  </SCRIPT>
          <title>Option test</title>
  </head>

  <body>
  <form action="" method="post" name="form1" id="form1">
  <select name="myoption"  onChange="myopen();">
                  <option value="Boy">Boy</option>
                  <option value="Girl">Girl</option>
                  <option value="Not Sure">Not Sure</option>
  </select>
  <br>
  <input type="text" name="myresult" value="">

  </form>

  </body>
  </html>

  Child Window

  <html>
  <head>
  <title>Untitled</title>
  <SCRIPT Language=Javascript>
  <!--
  function addoption(){
    var odoc=opener.window.document.form1
    odoc.myresult.value='result!'
    odoc.myoption.options[(odoc.myoption.options.length+1)]=new Option
  ('hi','hi')
    self.close();
  }
  //-->
  </SCRIPT>
  </head>

  <body>
  <A Href="#" onClick="addoption();">Click ME</A>

  </body>
  </html>

  Now the strange thing is, it works fine if the code is on the same page,
  but just won't work over two pages, note for a test I used a textbox
  aswell called myresult, the value gets sent through to this box correctly
  every time.

  Please help if you can.

  Cheers,

  Alex.

  ---

  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

  --- 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 ---



  Return to Index