2014年4月24日 星期四

javascript的子視窗,怎麼傳值到母視窗呢?

http://www.blueshop.com.tw/board/FUM20041006152641OLG/BRD20071024125802LHJ.html

message.php 母視窗

<html>
<head>
  <meta charset="UTF-8">
</head>

<body>

  <form  name="myForm" method="post" action="">
    <textarea id="matter" name="matter" cols="40" rows="10"></textarea>
    <input name="button" type="button"
      onClick="window.open('call-words.php','window', 
                                               'status,width=300,height=300,scrollbars')"    value="我的辭庫">
  </form>

</body>
</html>



call-words.php 子視窗

<html>
<head>
  <meta charset="UTF-8">
  <SCRIPT LANGUAGE="JAVASCRIPT">
    function writeBack(imgName) {
      opener.document.myForm.matter.value = imgName;
    }
  </SCRIPT>

</head>

<body>

  <form name="wordsform" action="" method="post">
    <input type="text" name="text1" value='自信心!'>
    <input type="button" value="引用"             
        onclick="writeBack(document.wordsform.text1.value)">
  </form>

</body>
</html>

沒有留言:

張貼留言