使用javascript关闭网页 [英] Webpage closing using javascript

查看:124
本文介绍了使用javascript关闭网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个页面,当用户要关闭此页面时,在这里我想在javascript中调用一个方法.为此,我在javascript中使用了onunload 方法.在这里,我要检查用户是要关闭页面还是要移至另一页面.如果他正在导航到另一页,我想停止执行此程序,否则需要使用window.open方法打开另一页.

请让我知道如何检查用户是要关闭页面还是要移至另一页面?

Hi,

I have a page, when user going to close this page, here I want to call a method in javascript. For this I used onunload method in javascript. Here I want to check whether the user is going to close a page or move to another page. If he is navigating to another page I want to stop the execution of this program otherwise need to open another page using window.open method.

Please let me know how to check whether the user is going to close a page or moving to another page??

推荐答案

您不能.当用户离开您的页面时,将调用onunload,并且其中不包含任何其他信息来告诉您他们去了哪里(可以理解,因为这将是一个主要的隐私问题).

您实际上想做什么?您所要求的听起来像是一场噩梦.我怀疑这个问题的正确答案是重新设计您的网站,使其像一个网站一样.
You can''t. onunload is called when the user leaves your page, and it doesn''t contain any extra information that tells you where they''ve gone (understandably, since that would be a major privacy issue).

What are you actually trying to do? What you''ve asked for sounds like a usability nightmare. I suspect the correct answer to this question is to redesign your website so it acts like a website.


这篇关于使用javascript关闭网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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