3

If anyone can guide a bit or have little knowledge how to make it possible, please let me know.

Thanks

Zeeshan
  • 98
  • 1
  • 4
  • 12
  • 3
    This isn't possible (unless you use a very insecure or broken browser). – George Cummins Jul 01 '11 at 21:22
  • It is possible to achieve this with extensions(firefox, chrome, etc), but not without it.. – Alfred Jul 01 '11 at 21:24
  • 1
    How do you think this should be possible with PHP? PHP is running on the server and has no access to the user's browser whatsoever. – Felix Kling Jul 01 '11 at 22:13
  • Oh sorry, we can't do this with PHP. Any script in Javascript is welcomed.. – Zeeshan Jul 02 '11 at 17:48
  • Just create a bookmark, and then drag the bookmark to a html form. This requires user interaction, but it is possible. – Dude Dawg Apr 10 '12 at 12:42
  • This question has an answer that explains how to do this using Javascript: http://stackoverflow.com/questions/11915370/retrieving-which-tabs-are-open-in-chrome – Anderson Green Aug 23 '12 at 21:32
  • Well , I don't know how to do it in java script and as others have already mentioned it . But if you want to use it as utility then panic button (https://chrome.google.com/webstore/detail/faminaibgiklngmfpfbhmokfmnglamcm/related) and panic room (https://chrome.google.com/webstore/detail/nlbgcjdlgkhnnkcfijfbdplpbbonnelf) are what you want. –  Sep 15 '12 at 11:39

3 Answers3

10

You can't, this information is just not available via any standard interface (except for a window you already have 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 massive invasion 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.

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.

Separately: This information is certainly not sent server-side (you tagged your question php).

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • +1 In addition, @Tariq can you imagine if a website was able to see what other sites you have open or have been visiting? How would you feel about that? – Matt Asbury Jul 01 '11 at 21:27
  • 1
    @Matt Actually there was some bug that allowed any site to guess the pages from the browsing history. It was based on the fact that the visited links can be colored differently and that the JS can read the resulting style (so you could guess URLs one by one, enter them somewhere and check their color to see whether they were visited). But it seems this has been fixed in modern browsers, AFAIK. – Tadeck Jul 01 '11 at 21:35
  • 1
    @Matt Update to my recent comment: Opera seems to be still vulnerable to this kind of "attack": http://jsfiddle.net/ePVas/1/ (JS in Opera is able to determine different color due to the link being visited before) – Tadeck Jul 01 '11 at 21:45
  • @Tadeck: **Very** interesting. Of course, you have to know what URLs you're looking for, but it's still a hole, and on the right (wrong) site, a very real opportunity for mischief. Wow. Pretty shocking that this is in the current Opera. – T.J. Crowder Jul 02 '11 at 09:24
  • 1
    @T.J. Crowder: I was also surprised. The problem here is that the attacker has unlimited number of attempts to "check" any number of URIs and do not even has to display them (http://jsfiddle.net/ePVas/2/). And even if recently installed update (Opera 11.50) it still exists... Yes, pretty shocking, but I suppose the bigger threat is the older IE versions with still significant market share. – Tadeck Jul 02 '11 at 10:47
  • @Tadeck: Yeah, I did a similar test ([here](http://jsbin.com/orulok/4), if you're interested). *"...but I suppose the bigger threat is the older IE versions with still significant market share"* Not as far as I can tell, I've tested IE6 (a mostly-unpatched IE6) through IE9, none of them seem to have this flaw. Full marks to Microsoft. I've tried various fairly recent versions of Firefox, Chrome, and Safari as well. None of them seems to have this hole other than Opera. – T.J. Crowder Jul 02 '11 at 10:50
  • @T.J. Crowder: Thanks, good to know only Opera fails to provide proper security here. I did not expect it :) – Tadeck Jul 02 '11 at 11:06
4

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 ::

var tabs = require("tabs");
for each (var tab in tabs)
  console.log(tab.url);

But this works only for Firefox Addons, not normal javascript.

Reference https://addons.mozilla.org/en-US/developers/docs/sdk/1.0/packages/addon-kit/docs/tabs.html

Hope this helps.

Pheonix
  • 6,049
  • 6
  • 30
  • 48
  • How can use this code and get the tab urls. Is this Javascript code ? If yes , then how do it use it. If no, is there any API which I need to use this functionality from ? – Zeeshan Jul 02 '11 at 18:18
  • If you are developing a Firefox Addon then you use this code to obtain the Tabs information, this code is not meant to be used in browser javascript. this should get you started :: https://developer.mozilla.org/en/extensions – Pheonix Jul 02 '11 at 21:01
  • Actually I don't want to create an extension, I want to make an html page that when I click a button, it gives me the list of all currently opened tabs' url. – Zeeshan Jul 03 '11 at 04:41
  • Then, theres no solution to that, atleast in the present web. – Pheonix Jul 03 '11 at 12:14
  • @Zeeshan actually extension is kind of html page (with some scripts and styles) just running in the browser environment, otherwise it's impossible to use browser's API... but in some cases you can run javascript in omnibox, or so called "bookmarklets" – AndriuZ Jan 26 '23 at 16:39
0

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.

Dude Dawg
  • 1,465
  • 2
  • 15
  • 26