3

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

Thanks

7
  • 3
    This isn't possible (unless you use a very insecure or broken browser). Commented Jul 1, 2011 at 21:22
  • It is possible to achieve this with extensions(firefox, chrome, etc), but not without it.. Commented Jul 1, 2011 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. Commented Jul 1, 2011 at 22:13
  • Oh sorry, we can't do this with PHP. Any script in Javascript is welcomed.. Commented Jul 2, 2011 at 17:48
  • Just create a bookmark, and then drag the bookmark to a html form. This requires user interaction, but it is possible. Commented Apr 10, 2012 at 12:42

3 Answers 3

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).

Sign up to request clarification or add additional context in comments.

7 Comments

+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 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.
@Matt Update to my recent comment: Opera seems to be still vulnerable to this kind of "attack": jsfiddle.net/ePVas/1 (JS in Opera is able to determine different color due to the link being visited before)
@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: 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 (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.
|
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.

5 Comments

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 ?
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 :: developer.mozilla.org/en/extensions
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.
Then, theres no solution to that, atleast in the present web.
@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"
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.