我想要显示一个弹出窗口(Google,Twitter等),当用户关闭该对话框时,我想要显示警告" bye",但该警报不会出现:
<script>
var openDialog = function(uri, name, options, closeCallback) {
var win = window.open(uri, name, options);
var interval = window.setInterval(function() {
try {
if (win == null || win.closed) {
window.clearInterval(interval);
closeCallback(win);
}
}
catch (e) {
}
}, 1000);
return win;
};
var test = function() {
alert("bye");
};
openDialog("//google.com", "popup", "scrollbars=no", "test");
</script>
答案 0 :(得分:3)
更改此代码
openDialog("//google.com", "popup", "scrollbars=no", "test");
与此:
openDialog("//google.com", "popup", "scrollbars=no", test);
答案 1 :(得分:0)
这一行:
openDialog("//google.com", "popup", "scrollbars=no", "test");
应阅读:
openDialog("//google.com", "popup", "scrollbars=no", test);
如果你想要,你也可以这样做:
openDialog("//google.com", "popup", "scrollbars=no", function(e){
alert("bye");
});