简体   繁体   English

jQuery获取beforeunload事件源ID

[英]jQuery get beforeunload event source id

I am trying to alert the user when they leave the shopping page with cart filled up. 我试图在用户离开购物车并装满购物车的时候提醒他们。 And also get feedback or the reason for their exit. 并获得反馈或退出原因。

I need to get event source id because to know whether they exit my site or navigate by clicking a link in my page. 我需要获取事件源ID,因为要知道它们是退出我的网站还是通过单击页面中的链接进行导航。

Any one help me on this... 有人在这方面帮助我...

It's not possible. 这是不可能的。 You should be able to catch if the user clicked a link to leave the page by manually setting up a listener event on each of them, but the browser does not give you any information about what led to the unload event. 通过在每个用户上手动设置一个侦听器事件,您应该能够捕获用户是否单击了链接以离开页面,但是浏览器没有提供有关导致卸载事件的原因的任何信息。 If it was an event ouside the document ("Back" button etc.), you're out of luck. 如果是一个事件导致文档被淘汰(“返回”按钮等),那么您很不走运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM