I have question :) Can I send message via Web Messaging or not to other tab in browser? For example I have openede my site, and now watching on other site. And when some condition will be pass my site sends messages which makes alert on the other page.
Asked
Active
Viewed 52 times
1 Answers
0
Assuming you have control over both pages, the answer is "yes", provided you open the second window from the first. window.postMessage
only works if you can get a handle to the window
. Therefore, if your background site were to invoke window.open()
to get to your "other" site, then you could retain a handle to it in your first page's script.
As far as opening it in a tab goes, you'll have to specify that in your browser options.
-
Uh. What, if I have control on first page and second page is, for example facebook? – user3025978 Mar 21 '14 at 20:30
-
1Then you can either petition Facebook to set up an alert API, or write a greasemonkey script or similar to install a message event listener. But it's not something you'll be able to rely on being available for anybody else. – Palpatim Mar 21 '14 at 21:20