【问题标题】:How to remove dialogue box from the exit popup window?如何从退出弹出窗口中删除对话框?
【发布时间】:2015-01-05 08:19:03
【问题描述】:

我想在关闭浏览器之前显示一个弹出窗口。这是我的代码。我使用了以下插件

http://kbeezie.com/cross-browser-exit-pop/

这里是演示http://kbeezie.com/exitpop.html

<script type="text/javascript">
function PopIt() { 
    $("a#trigger").trigger('click');
    window.onbeforeunload = UnPopIt;
    return "Would you like to join our mailing list for other offers?"; 
}

function UnPopIt()  { /* nothing to return */ } 

$(document).ready(function() {
    window.onbeforeunload = PopIt;

    $("a#trigger").fancybox({
        'hideOnContentClick': false,
        'showCloseButton': false
    });

    $("a[id!=trigger]").click(function(){ window.onbeforeunload = UnPopIt; });
});

但此代码显示“您想加入我们的邮件列表以获取其他优惠吗?”显示弹出窗口之前的问题。我想删除那个弹出问题,只在那里显示那个弹出窗口。

【问题讨论】:

标签: javascript jquery popup


【解决方案1】:

已编辑由于 OP 的 cmets。

您不能使用自定义的 onbeforeunload 模式。这是一项您无法绕过的安全措施。

原答案

只需将return "Would you like to join our mailing list for other offers?"; 的行更改为return "Your message goes here within the string";

【讨论】:

  • 请查看演示链接。
  • 我有。您的问题不是如何删除消息并可选择将其更改为其他内容吗?
  • 不。有两个弹出窗口,当您看到该问题时,只需单击“留在此页面”按钮,之后也会显示真正的弹出窗口。我想要第二个弹出窗口而不是问题。另一方面,我只想在关闭浏览器时显示第二个窗口。谢谢
  • 如果我的回答成功揭示了您的问题,请勾选绿色复选标记以帮助该网站的未来访问者:)