HTMLには2つの機能があり、1つはアラートのみ、もう1つはwindow.open()で定義済みのHTML文字列で新しいウィンドウを作成することです。親HTMLから関数を呼びたいと思います。私はparent.abcとwindow.parent.abcを呼び出してみました。どちらも動作しません。親からの呼び出し関数
<html>
<body>
<button onclick="myfunction()" type="button">A new Window</button>
<script>
var myWindow;
function abc() {
alert("abc");
};
function myfunction() {
var htmlholder = '<!DOCTYPE html>'+
'<html>'+
'<body>'+
'<p>Here is another HTML<\/p>'+
'<button type="button1" onclick="parent.abc()">Call parentabc<\/button>'+
'<\/body>'+
'<\/html>';
myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write(htmlholder);
};
</script>
</body>
</html>
ポップアップ/タブ 'opener'、フレームは' parent'を持っています。 – Teemu
ありがとうございます。 – user3707157