开发者

to get link clicked in javascript/firefox-adon

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.


The event handler should be binded to the window object, not to window.document. Any event listener which would be applied using <body on{name of event} ...> should dynamically be added to window instead of document / document.body.


window.onunload = funcRef;

For example: <title>onunload test</title>

<script type="text/javascript">

window.onunload = unloadPage;

function unloadPage()
{
 alert("unload event detected!");
}
</script>

Refer DOM section in Firefox/XUL: https://developer.mozilla.org/en/DOM/window.onunload

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜