How to manage one window from another in HTML5?

I am trying to control one window from another in HTML5. I would like it when I open one window that I enter, and another window that I enter, and then from one window I can click a button and something will happen in another window. I'm not sure where to start; can someone point me in the right direction?

+4
source share
3 answers

You do not need HTML5 functions for this, but you can easily do this with javascript:

myNewWindow = window.open() opens a new window and assigns the window object of this new myNewWindow window, so you can easily access the new DOM window from the opening script using myNewWindow -variable.

It also works differently: in a script in a new window, you can use window.opener to access the window object and the DOM of the opening window.

Just make sure that the content of all your windows is loaded from one domain, since javascript does not allow you to control the content downloaded from another source (for more details on this subject, see the "same origin policy").

+9
source

This answer was 6 months late, but for googlers (like me):

I would recommend WebSockets for what you are trying to do Jonathan. WebSockets allow the server to transfer data to any / all browser windows that are open for your page / site in real time.

Browser support is currently pretty poor , but there are good pads to make it work in all browsers very efficiently. Socket.io is one of those solutions that I used for great success.

+2
source

I think that JavaScript engines in browsers should allow open windows (from another URL / server) and use the new site as a person.

For example, if I am on site A, referring to a specific paragraph of the blog on site B, I should be able to insert virtual <a name=""> attributes based on the layout of the site / css site to scroll to the page.

-1
source

Source: https://habr.com/ru/post/1338815/


All Articles