Max*_*Max 18 html javascript iframe jquery
我需要捕获一个应该在iframe内容消失之前触发的事件.
我一直试图完成这样的事情
$iframe = $('iframe');
$iframe.beforeunload(function () {
debugger;
});
Run Code Online (Sandbox Code Playgroud)
要么
$iframe = $('iframe');
$iframe.unload(function () {
debugger;
});
Run Code Online (Sandbox Code Playgroud)
我甚至尝试将它绑定到iframe窗口本身没有任何运气
$iframe = $('iframe');
$iframe[0].contentWindow.onunload = function () {
debugger;
};
Run Code Online (Sandbox Code Playgroud)
这些事件处理程序实际上都没有触发我
而且我很困惑为什么.要重新加载我.reload()从iframe外部使用的iframe,从内部,我可能需要使用不同的方法吗?
Max*_*Max 30
弄清楚了!contentWindow重装后我不知道它的参考丢失了.
$iframe.load(function () {
$iframe[0].contentWindow.onbeforeunload = function () {
debugger;
};
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22023 次 |
| 最近记录: |