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
CHAR and VARCHAR types are similar, differing pri...
Table of contents A simple component example More...
Table of contents Demand Background Why use Nginx...
This article example shares the specific code for...
Table of contents origin Environmental Informatio...
In web page production, input and img are often pl...
In MySQL, database garbled characters can general...
List of HTML tags mark type Name or meaning effec...
When browser vendors bend the standards and take i...
Table of contents Introduction Description Naming...
1. Problem symptoms Version: MySQL 5.6, using the...
This article shares the specific code for JavaScr...
Glass Windows What we are going to achieve today ...
1. Pull the image docker pull registry.cn-hangzho...
MySQL 8 new features: My personal opinion on MySQ...