0

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.

  • if the site is already open, no need to open a new window, and just launch the video on the already open window.
  • if the site is not yet open, then open a window with the site and play.

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

Is there option in JavaScript?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
naveen
  • 3
  • 2

2 Answers2

2

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
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • oh.. :( but i want only know this site open or not? – naveen Aug 27 '13 at 12:06
  • Nice, you were quicker than me. As it to stream videos then this can be detected too rather than use heart beat. – Nick.T Aug 27 '13 at 12:07
  • "Only". Even if you could run executable code in an email, if that was possible it would enable some major invasions of privacy. So no, you can't, and you shouldn't be able to. – Quentin Aug 27 '13 at 12:07
0

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

Nick.T
  • 587
  • 4
  • 20