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?
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.
An <iframe> tag hosts a separate embedded window, with its own separate document and window objects. We can access them using properties: iframe.
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).
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With