views:

349

answers:

4

Can anyone help me by telling me how can I capture the URL of a new tab or a new window by using JavaScript in Firefox?

+4  A: 

You can't, unless you're talking about chrome (extension) code, or of course you're creating the new window (you can't programmatically create tabs outside of chrome) yourself.

Matthew Flaschen
+1  A: 

I don't think you can control whether firefox opens a new window/tab. It depends on how the user tries to open the link

Also, if the javascript is trying to open the window using window.open(...), you could store it in a variable & use the Location property to get the url from it.

shahkalpesh
A: 

FF stores all opened windows and tabs in sessionstore.js file. In windows it is situated in Application Data\Mozilla\Firefox\Profiles\.default\sessionstore.js. So if you're developing a plugin for FF, I think it is reachable. But if you're trying to access it from html page, it of course won't be.

glaz666
+9  A: 

I don't think it would be possible if a user opens a new tab or window. In case the window is opened by javascript, suppose by your extension, you may very well catch that window, like get window and then use window name that you give at the time of creation and then fetch the URL from there.

sumit_programmer