私が作成したこの質問に続いて、iframeのjavascriptでwindow.open関数をオーバーライドしようとしました。これを試しました:
var frame = document.getElementById('myFrame');
if (frame) {
frame.contentWindow.open = function (url, windowName, windowFeatures) {
// do whatever you want here (e.g. open an ajax modal frame)
};
}
しかし、メソッドをオーバーライドしようとすると、「オブジェクトはこのアクションをサポートしていません」というエラーが表示されます
何か案は?
前もって感謝します
編集: 私がやろうとしていることについての詳細を添付します
これは私のiframe定義です
<iframe id="ifr" src="Init.html" enableviewstate="true" width="900px" height="900px" frameborder="1" runat="server" style="z-index:0" clientidmode="Static"><p>Su navegador no soporta iframes.</p></iframe>
これは私のJavaScriptコードです
document.getElementById("ifr").contentWindow.open = function (url, windowName, windowFeatures) {
// do whatever you want here (e.g. open an ajax modal frame)
alert("hello");
ifropen();
};
document.domain (現在の Web ページ) では "localhost" を取得しますが、iframe の document.domain では "undefined" を取得します