JavaScript で新しいウィンドウを開き、オープナー ウィンドウからいくつかのデータを表示したいと考えています。私が読んだものに基づいて、私はこれを作りました:
MainWindow.html
<html>
<head>
<script>
function OpenNewWindow()
{
this.MainWindowData = 123123;
document.write(this.MainWindowData);
var wnd = window.open("NewWindow.html");
wnd.NewWindowData = 787878;
}
</script>
</head>
<body>
<input type="button" value="Open Window" onclick="OpenNewWindow()">
</body>
</html>
NewWindow.html:
<html>
<head>
<script>
function ShowData()
{
document.write("NewWindowData: " + this.NewWindowData + "<br />");
document.write("MainWindowData: " + window.opener.MainWindowData);
}
</script>
</head>
<body>
<input type="button" value="Show Data" onclick="ShowData()">
</body>
</html>
問題は、両方の変数が未定義のままであることです。
事前に助けてくれてありがとう。