如何获取onbeforeunload事件的目标URL? [英] How can I get the destination URL for the onbeforeunload event?

查看:190
本文介绍了如何获取onbeforeunload事件的目标URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了几个小时,但我找不到解决方法。

I've searched for hours, but I couldn't find a solution for this.

window.onbeforeunload = warn;

这不起作用:

function warn (e) 
{ 
   var destination = e.href;
   alert(destination );
}

好的,所以要清除这些东西。如果用户单击页面本身上的链接,则很容易,因为您可以将事件处理程序添加到所有链接onclick事件,但是。我想抓住地址,用户在浏览器的网址框中键入的内容。

Okay, so to clear the things. If the user clicks on a link on the page itself, it is easy, because you can add an eventhandler to all of the links onclick event, but. I want to catch the address, what the user types into the url box of the browser.

推荐答案

因为它不能完成。新位置是私人/敏感信息。
没有人希望您知道他们离开您的网站时访问了哪些网站。

Because it can't be done. The new location is private/sensitive information. Nobody wants you to know which sites they visit when they leave your site.

这篇关于如何获取onbeforeunload事件的目标URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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