当我的网站的用户关闭窗口或离开我的网站时,我们如何显示确认div? [英] How do we show confirmation div when a user of my website closes the window or navigates away from my website?

查看:59
本文介绍了当我的网站的用户关闭窗口或离开我的网站时,我们如何显示确认div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个计划,需要在我的网站用户关闭浏览器窗口时向他们显示确认div.

我已经找到了在javascript确认消息中显示确认消息的代码(使用onbeforeunload),但是我需要在div中显示消息.

还请建议我是否可行.

谢谢
Ashish

Hi all,

I have a scnario where I need to display a confirmation div to users of my website whenever they closes the browser window.

I have found the code to show confirmation message in javascript Confirmation message (using onbeforeunload), but I need to display message in div.

Also please suggest me whether it''s possible or not.

Thanks
Ashish

推荐答案

在"onbeforeunload" javascript事件上,调用javascript函数,该函数将向用户显示/显示div.肯定会起作用
On the ''onbeforeunload'' javascript event, call the javascript function which will show/display the div to the user. It will work for sure


给您的div一个ID,例如"kas",然后在Java脚本中编写此代码


give your div a id such as "kas" then write this code in java script


<script type="text/javascript">
    window.onbeforeunload = function() 
{ 
   document.getElementById('kas').style.visibility = 'visible';
}
</script>



但请记住,在显示该div之后,您将无法看到div因为该页面将立即关闭,直到您显示任何警报框或停止页面的卸载为止



but keep in mind that you will not be able to see that div becouse page will close itself right after displaying that div until you diplays any alert box or stops page from unloading


这篇关于当我的网站的用户关闭窗口或离开我的网站时,我们如何显示确认div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆