2

この index.php ファイルがあります。

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Proj</title>
        <script type="text/javascript">
            function openWindow() {
                window.open("popup.php", "popup_id", "scrollbars=no,resizable,width=200,,left=300,top=300,height=200");
            }
        </script>
    </head>
    <body>
        <form name="form1" action="">
            <input name="initialdata" type="text" value="initial data" />
            <input type="button" value="Send" onClick="openWindow()" />
        </form>
    </body>
</html>

そしてこのpopup.phpファイル

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>popup</title>
        <script type="text/javascript">
            function putData() {
                //How to copy from that file -> document.formname.popupdata.value to 
                //index.php -> document.form1.initialdata.value???
                window.close();
            }
            function loadData() {
                //how to get the value "initial data"
                //from index.php -> document.form1.initialdata.value????????????
            }
        </script>
    </head>
    <body onLoad="loadData();">
        <form name="formname" action="">
            <input name="popupdata" type="text" value="" />
            <input type="button" value="Send" onClick="putData()" />
        </form>
    </body>
</html>

index.php -> document.form1.initialdata.value から値「初期データ」を取得する方法と popup.php -> document.formname.popupdata.value から index.php -> document.form1 にコピーする方法.initialdata.value??

4

1 に答える 1

1

使用する

window.opener.document.getElementsByName("initialdata")[0].value;

ただし、これはすべてのブラウザーで機能するとは限りません。詳細については、次の質問を参照してください。

window.opener の代替

于 2012-08-22T16:44:10.280 に答える