[thelist] An annoying Javascript problem

Joshua OIson joshuao at fought.org
Sat Sep 23 05:45:04 CDT 2000


Though that code works, it's overly complex.  If you are looking for a very
simple solution, the following HTML and JavaScript shows another way to
accomplish the cross window communications:

--------------- parent.html ----------------------

<script>
  var parentvar = 'This is the variable from the parent window!';

  function openChild()
  {
    var w = window.open('child.html','child');
  }

  function getVar()
  {
    return parentvar;
  }
</script>

<HTML>
<form>
data: <input type="input" name="data1" onchange="parentvar = this.value;">
<input type="button" value="Throw" onclick="openChild();">
</form>
</HTML>

------------------- child.html ------------------------------

<HTML>
<BODY>
<script>
document.write(self.opener.getVar());
</script>
</BODY>
</HTML>


Hope this helps,
-joshua





More information about the thelist mailing list