Javascript 如何使用php或javascript获取所有浏览器中当前打开的标签的url?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6553334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the url of currently opened tabs in all browsers with php or javascript?
提问by Zeeshan
If anyone can guide a bit or have little knowledge how to make it possible, please let me know.
如果有人可以指导一下或对如何使其成为可能知之甚少,请告诉我。
Thanks
谢谢
回答by T.J. Crowder
You can't, this information is just not available via any standard interface (except for a window you alreadyhave a reference to). You can see why. You wouldn't want the site owner for one of your tabs to be able to know what all your other tabs were showing, that would be a massiveinvasion of your privacy.
你不能,这个信息不能通过任何标准界面获得(除了你已经引用的窗口)。你可以明白为什么。您不希望您的一个选项卡的站点所有者能够知道您所有其他选项卡显示的内容,这将是对您隐私的大规模侵犯。
For windows you already have a reference to, you can get the URL of whatever that window is showing (window.location.href
), and possibly that of its parent window (window.parent.location.href
), top-level (window.top.location.href
), and subordinate frames (window.frames[n].location.href
— I think). But that's not going to get you the tabs you asked for.
对于您已经引用的窗口,您可以获得该窗口显示的任何内容的 URL ( window.location.href
),可能还有其父窗口 ( window.parent.location.href
)、顶级 ( window.top.location.href
) 和从属框架 ( window.frames[n].location.href
— 我认为)的 URL 。但这不会让您获得您要求的标签。
This information is likely available via the extension mechanism of various browsers (Firefox add-ins, Chrome Extensions, etc.), but that would be only for a browser extension, which requires an explicit install from the user, and (currently) requires writing one for each browser vendor, where not all vendors offer an extension mechanism.
此信息可能通过各种浏览器(Firefox 插件、Chrome 扩展程序等)的扩展机制获得,但这仅适用于需要用户显式安装的浏览器扩展,并且(当前)需要编写每个浏览器供应商都有一个,其中并非所有供应商都提供扩展机制。
Separately: This information is certainly not sent server-side (you tagged your question php
).
单独:此信息肯定不会发送到服务器端(您标记了您的问题php
)。
回答by Pheonix
if you are expecting to do it from a web page, then you cannot get that through any language executed on Serverside or Client Side.
如果您希望从网页上执行此操作,则无法通过在服务器端或客户端上执行的任何语言来实现。
If you asked in context for Firefox Addons, this might help ::
如果您在 Firefox Addons 的上下文中询问,这可能会有所帮助 ::
var tabs = require("tabs");
for each (var tab in tabs)
console.log(tab.url);
But this works only for Firefox Addons, not normal javascript.
但这仅适用于 Firefox 插件,不适用于普通的 javascript。
Reference https://addons.mozilla.org/en-US/developers/docs/sdk/1.0/packages/addon-kit/docs/tabs.html
参考 https://addons.mozilla.org/en-US/developers/docs/sdk/1.0/packages/addon-kit/docs/tabs.html
Hope this helps.
希望这可以帮助。
回答by Dude Dawg
Actually there is a way, just bookmark all tabs and then drag the bookmark somewhere, for instance to a html form, and then you can use for instance javascript to read it from there. I don't know about other browsers yet, but in firefox you get the bookmark name, followed by all the urls, everything separated by newlines, no trailing newline at the end.
实际上有一种方法,只需为所有选项卡添加书签,然后将书签拖到某个地方,例如到 html 表单,然后您可以使用例如 javascript 从那里读取它。我还不知道其他浏览器,但在 firefox 中,你会得到书签名称,然后是所有的 url,所有的东西都用换行符分隔,最后没有换行符。