mač*_*ček 8 javascript jquery jquery-ui
我曾经习惯window.onbeforeunload在用户试图离开网站时显示自定义消息.
例:
window.onbeforeunload = function(){
if(some_condition){
return "Are you sure you want to navigate away from this page?\nAll unsaved changes will be lost.";
}
};
+--------------------------------------------------------+
| Are you sure you want to navigate away from this page? |
| All unsaved changes will be lost. |
| |
| [ Yes ] [ Cancel ] |
+--------------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)
但是,我想稍微提高一点.如果可能的话,我想使用自定义模式表单而不是通用弹出窗口.
有没有办法做到这一点?
绑定到HTML对我来说非常有效,而不是卸载.这个原因在另一个答案中得到了很好的解释.
$("html").bind("mouseleave", function () {
$('#emailSignupModal').modal(); \\or any modal
$("html").unbind("mouseleave");
});
Run Code Online (Sandbox Code Playgroud)
如果您想在一天中或仅在任何其他特定条件匹配时显示模态,那么您可以使用cookie.
| 归档时间: |
|
| 查看次数: |
18967 次 |
| 最近记录: |