基本的に、コンテンツが同じオリジンからのものであっても、コンテンツが別のドメインからのものであるかのように常に制限する iFrame が必要です。
これを行う方法はありますか?
基本的に、コンテンツが同じオリジンからのものであっても、コンテンツが別のドメインからのものであるかのように常に制限する iFrame が必要です。
これを行う方法はありますか?
これはwindow.parent
子フレーム/ウィンドウでは非表示になりますが、top
プロパティでは非表示になります。
window.parent
ただし、子ウィンドウ/フレームの onload イベントが終了するまで、プロパティには引き続きアクセスできます。
<html>
<head>
<style type="text/css">
#wrapper {width:1000px;height:600px;}
</style>
<script type="text/javascript">
window.onload = function() {
var frm = document.getElementById('childFrame');
var win = frm.contentWindow || (frm.contentDocument && frm.contentDocument.parentWindow) || (frm.document && frm.document.parentWindow);
if (win) win.parent = null;
}
</script>
</head>
<body>
<div id="wrapper">
<iframe id="childFrame" src="child.html" frameborder="0" style="width:100%;height:100%;"></iframe>
</div>
</body>
</html>