Communication between different windows in one domain

I am creating an application that does a lot of loading and processing data on the client side. Data processing is isolated from the main application by processing in an iframe, which is located in a subdomain. It is this iframe that loads the data. Communication is through postMessage.

Everything works fine, except that it might be better.

If the user opens additional tabs / windows, the application currently reloads all the data and can even perform duplicate processing, which is not a problem, except that it slows down everything, and pages take longer.

I would like each tab / top-level window to be associated with only one iframe processing, which can be restored if the original window is closed. The problem is that they do not open with javascript, but with the usual browser methods open tab links, so I can’t get the iframe link that is needed to send the message.

In any case, can I pass the window link for the iframe to other tabs so that they can communicate with it through postMessage? Can this be achieved using common workers?

I understand that I could use shared workers for the entire processing task, but this would have problems, because the data comes from third-party domains that cannot be accessed from the worker.

Only compatibility with the latest versions of all major browsers is required.

: , SharedWorker firefox, , . ?

2: , :

var win = window.open('', 'my_window_name'); 

iframe . , iframe , . , " " , .

+5
1

- , . . . , .

.

-,

remote_window = window.open("", "remote_window_name");

. , , , , .

, iframe , . . /, localStorage, , iframe. , iframe , , .

, , try . try . , , , , , , " ". - .

try {
    if(store_window.location.href === "about:blank" ){
        remote_window.close();
        remote_window = insertIfame();
    }
} catch(err) {
}

onunload, .

setInterval, -. 4 ; /, , iframe, . , , , iframe. , , onunload - . - 1 - , . -, , .

, , iframe. , iframe , , reset.

. event.source - .

- , iframe - . , onunload iframe . , , . , , , , , -.

+3

All Articles