在 javascript/firefox-adon 中单击链接
下面是 Firefox 插件的代码片段,其部分工作是获取用户的导航详细信息(从哪个页面到哪个页面等),但我使用的代码似乎不起作用:
window.document.onunload = function()
{
alert(document.location.href);
alert(document.referrer);
}
重要提示: 窗口的 onunload 事件在浏览器关闭时调用。我希望在卸载浏览器中的每个页面时调用该函数。
Below is a code snippet for a Firefox add-on whose part of the job is to get the navigation details of the user (from which page to which page etc), but the code I used doesn't seem to work:
window.document.onunload = function()
{
alert(document.location.href);
alert(document.referrer);
}
IMPORTANT NOTE: The onunload event for the window is called when the browser is closed. I want the function to be called when each page in the browser is unloaded.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事件处理程序应绑定到
window
对象,不绑定到window.document
。任何使用应用的事件侦听器都应动态添加到
window
而不是document / <代码>文档.body。
The event handler should be binded to the
window
object, not towindow.document
. Any event listener which would be applied using<body on{name of event} ...>
should dynamically be added towindow
instead ofdocument
/document.body
.window.onunload = funcRef;
例如:onunload test
请参阅 Firefox/XUL 中的 DOM 部分:https://developer.mozilla.org/en/DOM/window.onunload
window.onunload = funcRef;
For example:
<title>onunload test</title>
Refer DOM section in Firefox/XUL: https://developer.mozilla.org/en/DOM/window.onunload