窗口关闭前弹出 [英] Popup before window is closed
问题描述
我想在按下浏览器关闭按钮时打开一个自定义弹出框,我想向退出的用户问一个问题,为什么他们要离开我的网站.我已经检查了很少的帖子,但是我发现最好的东西就是这样的帖子
I want to open a custom popup box when browser close button is pressed, I want to ask a question to the users exiting that why are they leaving my site. I have checked quite few posts but the best thing I found is something like this post
http://stackoverflow.com/questions/10847156/jquery-dialog-box-before-closing-browser-window
但这只是打开浏览器默认确认框.我想打开一个自定义框,例如colorbox.我的页面是http://cwstudio.in/browserclose/
But this just opens a browser default confirm box. I want to open a custom box like colorbox. My page is http://cwstudio.in/browserclose/
现在我正在使用alert
功能打开弹出窗口,但是如果我不使用警报,浏览器将不等待我的弹出窗口而只是将其关闭.
right now I am using alert
function to open the popup but if I donot use the alert, the browser donot waits for my popup and just close it.
感谢您的帮助.
谢谢
推荐答案
简单地
window.onbeforeunload = function () {
return 'Any string';
};
这篇关于窗口关闭前弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!