如何检测访问者何时离开公司内部网上的我的页面/网站以及他们要去哪里?
在我们的内部 Intranet 上,我们有几个嵌入式帮助文件链接到我们的内部应用程序中。我试图确定用户是否仅使用特定于应用程序的内部帮助文件,或者他们是否正在访问其他资源,例如我们的内部 wiki、论坛、时事通讯等,或者可能是外部资源。
我尝试使用 onbeforeunload 返回 document.location.href,但它无法按我需要的方式工作。例如,如果用户位于internalhelp.company.com/page1.html,然后离开该页面前往internalwiki.company.com/wikipage1.php,则onbeforeunload 将返回internalhelp.company.com。我需要它来返回internalwiki.company.com。
任何帮助将不胜感激。
谢谢。
On our internal intranet, we have several embedded help files linked to from within our internal applications. I'm trying to determine whether or not the user is solely using our internal help files specific to the application or if they're visiting other resources such as our internal wiki, forums, newsletters, etc.. or possibly external sources.
I tried using onbeforeunload to return document.location.href, but it doesn't work as I need it to. For example, if the user is at internalhelp.company.com/page1.html and then leaves the page to go to internalwiki.company.com/wikipage1.php, the onbeforeunload returns internalhelp.company.com. I need it to return internalwiki.company.com.
Any help would be greatly appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
出于隐私原因,这是完全不可能的。
如果您只对超链接感兴趣,您可以向所有
标记添加一个点击处理程序,该处理程序会发送一个 AJAX 请求,告诉您该链接已被点击(或使用服务器端插页式页面) )
For privacy reasons, this is totally impossible.
If you're only interested in hyperlinks, you could add a click handler to all
<a>
tags which sends an AJAX request telling you that the link was clicked (or use a server-side interstitial page)据我所知,仅使用 JavaScript 是不可能做到这一点的。出于安全原因,JavaScript 被沙箱化 - 在这种情况下,它被限制在加载脚本的页面中。您必须使用浏览器扩展程序或页面范围之外的其他内容。
As far as I know, this isn't possible to do with just JavaScript. For security reasons, JavaScript is sandboxed - in this case, it's confined to the page in which the script was loaded. You would have to use a browser extension, or something else that exists outside of the page scope.
获取一些信息的一种方法是,如果您拥有帮助站点的管理/内容控制权,则可以使用您自己的 URL 封装外部链接,该 URL 可以记录用户的点击情况。
例如,Facebook 上的大多数/所有外部链接都是以下形式:
这样,Facebook 就可以记录 outclick。
如果您无法访问帮助网站上的链接,您就会陷入困境(出于隐私原因,出于设计目的,否则任何人都可以编写 JavaScript 来跟踪用户正在做什么以及他们要去哪里)。
One way to get some information, IF you have administrative/content control of the help site, is to wrap a external links with your own URL that can log the user clicking out.
For example, most/all external links on Facebook are of the form:
This way, Facebook can log the outclick.
If you don't have access to the links on the help site, you're stuck (for privacy reasons, by design -- otherwise anyone could write JavaScript that tracks what users are doing and where they're going).
您可以在加载每个页面时使用 javascript 设置 cookie。然后当它们关闭时,您可以调用 window.unload 函数。在此功能中,您可以删除该页面的 cookie。然后,当没有 cookie 时,用户会从浏览器中退出该网站。难道就不能实施吗?
You can set cookie for each page using javascript when they are loaded. Then when they are closed you can call
window.unload
function. In this function you can remove the cookie for that page. Then when there are no cookie user exits the site from browser. Can't it be implemented?