S_a_k_Uの日記みたいなDB

~サクゥーと呼ばないで~

親は親

obacheの助言に基づき検証。
遷移先にopenerをどうやって渡そうか考えてたけど、よう考えたら同じwindowで遷移だったらopenerは一緒なのね。
コード選択画面は、選択ボタンで親に選択したコードを返してから、windowを閉じればいいらしいので、こんな感じでOKみたい。

【親画面[p.html](変わらず)】
<html>
  <head>
    <title>親画面</title>
    <script type="text/javascript">
      function openChild() {
        window.open("http://[IPアドレス]/c.html", "child");
      }
    </script>
  </head>
  <body>
    <input type="input" id="hoge" name="hoge" value="xxx" />
    <br />
    <input type="button" id="but" name="but" value="open" onclick="openChild();" />
  </body>
</html>

【子画面[c.html]】
<html>
  <head>
    <title>子画面</title>
    <script type="text/javascript">
      function setVal() {
        var val = window.document.getElementById("hoge").value;
        var url = "http://[ホスト名]/x.html?hoge=" + escape(val);
        window.open(url, "_self");
      }
    </script>
  </head>
  <body>
    <input type="input" id="hoge" name="hoge" value="" />
    <br />
    <input type="button" id="but" name="but" value="set" onclick="setVal();" />
  </body>
</html>

【代理子画面[x.html]】
<html>
  <head>
    <title>代理子画面</title>
    <script type="text/javascript">
      var param = document.location.search;
      param = param.substring(1, param.length);
      params = param.split("&");
      for ( var i = 0 ; i < params.length ; i++ ) {
        var p = params[i].split("=");
        window.opener.document.getElementById(p[0]).value = unescape(p[1]);
      }
      window.close();
    </script>
  </head>
  <body>
  </body>
</html>