views:

129

answers:

1

I am creating a Firefox extension where I need to find out what was the last location visited in another window. Here is an example of what I mean. I present the user with a list of sites from a main interface window. The user clicks on one of the sites and a new window is opened to that site. From there, the user will navigate the site in the new window and will eventually stop browsing or close the window. I need to find out what was the last visited location from that window. Also, the user may be navigating more than one site at a time, so there could be many windows open. I need to know what was the last location for every one of them. So far, the only way that I got it to work is to use a timer and poll the new window every second for document.location.href. There must be a better way.

+1  A: 

As far as I know this is not possible in (pure) Javascript due to security/privacy considerations. On the other hand, since you are writing a Firefox plugin you have additional mechanisms you can use.

For instance, you can create a greasemonkey plugin that is applicable to every site. This plugin will record the href using GM_setValue(). The main plugin will read this information via GM_getValue().

Itay