'Build communications between tabs
I am trying to create a communication channel between tabs. In my main tab I have the following:
window.addEventListener("message", (event) => {
console.log(event.data);
}, false);
I am opening new tab using this code:
window.open('https://localhost/newtab.html', '_blank');
In the newtab.html I hav this code:
<html>
<body>
<script>
window.postMessage('message', 'abc');
</script>
</body>
</html>
Both target tab and new tab are on the same domain. I am not getting into target tab when opening a new tab. What am I missing?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
