开发者

Mozilla plugin get the previous tab url of the most recent tab

开发者 https://www.devze.com 2023-02-25 00:02 出处:网络
I have a question about how to get the previous tab url in Mozilla plugin after adding a new tab. The flow is having Tab_A focused, when user click a button, a new tab Tab_B will be added and focused

I have a question about how to get the previous tab url in Mozilla plugin after adding a new tab.

The flow is having Tab_A focused, when user click a button, a new tab Tab_B will be added and focused. Tab_B开发者_JAVA百科 will need the url of Tab_A for processing.

My current solution is, before the new tab Tab_B is loaded (by using listener), i save the url of Tab_A into my extension nsIPrefBranch, so i can read this url when Tab_B (window) is loaded.

I am just wondering if there is a better way of retrieving Tab_A's url in this case, thanks.


As far as I know getting the previously closed is not defined in docs but doing that isn't difficult as well. You can create a global variable on the overlay.js and store the previously closed tab. I think you don't even need to store it in the preferences incase you want to continue from previously Firefox closed session.


When tab B's document loads, its referrer should be tab A's URL, and its opener will be tab A's contentWindow (assuming it was opened by script in tab A).

0

精彩评论

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

关注公众号