Scenario: When page A opens page B, after operating on page B, page A needs to synchronize the changed data Page A, http://127.0.0.1:10001/A.html var domain = 'http://127.0.0.1:10001'; window.open('http://127.0.0.1:10001/B.html'); window.addEventListener('message', function (event) { if (event.origin !== domain) return; console.log('message received: ' + event.data, event); }, false); B page, http://127.0.0.1:10001/B.html, opener is the reference to the opener of the current window var domain = 'http://127.0.0.1:10001'; window.opener.postMessage("success", domain); window.close(); If A needs to open B and send data to B at the same time // Sending data var domain = 'http://127.0.0.1:10001'; var myPopup = window.open('http://127.0.0.1:10001/B.html'); myPopup.postMessage('data', domain); // Receive data window.addEventListener('message', function(event) { if(event.origin !== 'http://127.0.0.1:10001') return; console.log('message received: ' + event.data,event); },false); The above is the details of how to use js to communicate between two html windows. For more information about js communication between two html windows, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Analyze Mysql transactions and data consistency processing issues
Table of contents Solution Analysis slice Resume ...
1. Parent components can pass data to child compo...
How to find slow SQL statements in MySQL? This ma...
This article example shares the specific code of ...
A Brief Discussion on the Navigation Window in If...
mysqladmin is an official mysql client program th...
I encountered this problem when I was making the ...
In-depth understanding of this in Js JavaScript s...
Installation path: /application/mysql-5.5.56 1. P...
The emergence of jQuery has greatly improved our ...
The login interface of WeChat applet is implement...
Recently I used MySQL to export table data to an ...
You must have inspiration to design a website. Goo...
I re-read the source code of the Fabric project a...
This article summarizes the implementation method...