javascriptで親ウィンドウのタイトルを見つけるにはどうすればよいですか?
私が使う
alert(window.parent.document.FormName);
と
alert(window.parent.document.title);
と
alert(window.parent.parent.document.title);
しかし、結果は真実ではありませんでした。
javascriptで親ウィンドウのタイトルを見つけるにはどうすればよいですか?
私が使う
alert(window.parent.document.FormName);
と
alert(window.parent.document.title);
と
alert(window.parent.parent.document.title);
しかし、結果は真実ではありませんでした。
ソリューションにこのコードを使用する
pageMain.html
<html>
<head>
<title>Parent Window</title>
</head>
<body>
<input type="text" id="data" value="23444" />
<a href="#" onclick="javascript:openChildWindow();">Open Child Popup window</a>
</body>
<script>
function openChildWindow() {
window.open('page1.html','childWindow','width=400,height=400');
}
</script>
</html>
page1.html
<html>
<head>
<title>Child Window</title>
</head>
<body onload="initializeMainDiv();">
<div id="mainDiv"></div>
</body>
<script>
function initializeMainDiv() {
alert( window.opener.document.title )
}
</script>
</html>
parent
別のサーバーにあるからウィンドウのタイトルにアクセスしようとしている可能性がiframe
あります。セキュリティ上の理由から、それは不可能です。