Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control one window from another in HTML5?

I'm trying to control one window from another in HTML5. I'd like it so when I open one window that I log into, and another window that I login to, then from one window I can click a button and something happens in the other window. I'm not sure where to start; can somebody point me in the right direction?

like image 236
Jonathan Ogle-Barrington Avatar asked Feb 08 '11 09:02

Jonathan Ogle-Barrington


People also ask

How do I open a web page in a new window?

Using Right Click. Right click on the link on your current window. Choose Open in New Window . The page will open in a new window.

Do iframes have their own window?

An <iframe> tag hosts a separate embedded window, with its own separate document and window objects. We can access them using properties: iframe.

What is the second parameter of window open () method?

URL: This optional parameter of the window. open() function contains the URL string of a webpage, which you want to open. If you do not specify any URL in this function, it will open a new blank window (about:blank).


1 Answers

You don't need any HTML5-Features for that but you can easily do it with javascript:

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

It also works the other way: In a script in the new window, you can user window.opener to access the window-object and DOM of the opening window.

Just make sure, that the content of all your windows is loaded from same domain, as javascript does not allow you to control content loaded from another source (refer to "same origin policy" for more information on this topic).

like image 71
Simon Avatar answered Oct 05 '22 03:10

Simon