0

我需要在我的购物车网站中使用 jquery Exit 弹出窗口。如果有人试图退出网站,那么会有 10% 的折扣弹出窗口让他留在那个页面上。我搜索了很多,但只有确认框的示例。

谁能告诉我这样做的例子。

4

1 回答 1

0

I believe this is simply not possible. If you could do whatever you want when user tries to leave the page you could e.g. never let him to do so. In other words - you can not display custom popup INSTEAD of the default dialog.

What you CAN do is to display standard dialog and do something in background. E.g.

<script type="text/javascript">
    $(window).bind('beforeunload', function() {
        window.discountPercent = 10;
        $("body").append("<strong>You now have a " + discountPercent + "% discount!</strong>");
        return 'You will get a discount if you dont leave. Still wanna leave?'; 
    });
</script>
于 2013-05-05T21:50:01.203 回答