tags:

views:

49

answers:

5

Hi, is it possible to get the addresses of web pages being opened in web browser using javascript?

Lets say that before performing some operation i need to check whether specific page is opened in the browser. Javascript's window.open() seems wrong to me, as it opens the window even if page was loaded before.

EDIT: i need to check if specific page is loaded in any tab of the browser, and if it is, i need to perform some operations on this page

+2  A: 

You mean you want to check if they have another window/tab open with some page? If so, then no, that isn't possible since it would be a major security problem.

thenduks
+1  A: 

If you mean the current window, accessing document.URL via the DOM will return what you want. If you mean some other tab/instance, as mentioned, no (unless you're working from inside a browser plugin).

Marc Bollinger
A: 

If you are only opening pages on your domain you could use a cookie to track what pages are opened. If not then as the others have said no you can't.

qw3n
+1  A: 

If this for internal use, you can develop a browser extension or, simpler, see Jetpack for Firefox. You can very easily access to each tab with the latter.
Any person that wish to use your script'll have to install the Jetpack extension, visit your webpage for download and accept the automatic installation it'll offer.

Felipe Alsacreations
+1  A: 

I would like to add to the "No" list, but with one interesting exception:

If you need to check if some particular page was ever loaded by a user (more specifically, if it is still in history of a browser), then you could do the following:

<style>
  a:visited { color: #00ff00 }
  a.check-facebook { display: none }
</style>

<a class="check-facebook" href="http://www.facebook.com"&gt;&lt;/a&gt;

<script>
  if (jQuery('.check-facebook').css('color') == 'rgb(0, 255, 0)') {
      alert('The person has visited http://www.facebook.com');
  } else {
      alert('Facebook homepage is not in the history of the browser')
  }
</script>
Vilius Pau