naveen
naveen

Reputation: 3

how to find particular site is already open or not in the browser?

I have sent Email to My client with some links.. (http://example.com?id=1234).

When the User click this link, It will open a new tab and play same Video's using iFrame.

How can i find the site (http://example.com) already opened or not?

Is there option in JavaScript?

Upvotes: 0

Views: 811

Answers (2)

Nick.T
Nick.T

Reputation: 577

For security reasons this is not possible directly in JavaScript. But you can work around and add a marker in the URL then detect server side if the site is already streaming the video to that computer (match with URL marker, IP and browser).

Upon response the server can say close or not...

Upvotes: 0

Quentin
Quentin

Reputation: 944528

There is no way to run any client side code in an HTML formatted email. So this is impossible.

The closest you could come would be to:

  1. use some kind of token to identify a user (e.g. stored in a cookie)
  2. run some heart beat code to see if they are still on the page (e.g. use XMLHttpRequest to request a 1 byte file every 15 seconds using a page id generated when the page was loaded and the user id in the cookie)
  3. check on the server to see if a heart beat from a different page was received recently when a new copy of the page is loaded
  4. serve different content if it is

Upvotes: 2

Related Questions