Send Data Between Tabs and Windows! - Broadcast Channel API in JavaScript
HTML-код
- Опубликовано: 14 июл 2019
- The Broadcast Channel API in JavaScript allows you to send data (or messages) between different browsing contexts (i.e. Tabs, Windows, IFrames etc.)
It's very easy to do and you can send almost anything such as Strings, Objects, Arrays and even Blobs. In this video, I'll show you how to use it.
Support me on Patreon:
/ dcode - with enough funding I plan to develop a website of some sort with a new developer experience!
For your reference, check this out:
developer.mozilla.org/en-US/d...
Follow me on Twitter @dcodeyt!
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Thank you for showing multiple examples. All the sites I've seen just regurgitate the basic documentation that i can find on MDN.
I always wondered about this. But I was too lazy to search this out. Thankfully I had turned on the bell of your channel.
nice video tut, i have never heard about Broadcast channel API
I found it very useful. Thanks
awesome. I even forgot about this possibility, thankfully your video was first on my request)
Thank you!
00:14 browser contexts, tab windows and s
What font and theme are you using?
Hi Dcode, How to make server tells client js that some data have been changed.
115 like
Useful channel
Sir please make tutorial on how to print emoji in any coding language javascript , html,php using vscode editor extension.
-_-
p
You can print (i think you meant console.log) in any code by using the following code in javascript
var emoji = '\u{1F44D}'; //Replace the following unicode with your unicode like the following
console.log(emoji);
Hope this help if you have any doubt about this you can ask me😄
is it possible to send a message from one Tab(youtube page) to other Tab(Facebook)
Nah, you can't do that
@@dcode-software is it possible by using an Extension?
Not sure, probably not cos it'd be a security issue
@@dcode-software ok ...thanks sir,
Is there a way to broadcast messages through different origin? I mean if the port and host are not the same of two tabs.
Short answer: No.
From MDN: The BroadcastChannel interface represents a named channel that any browsing context of a given origin can subscribe to. It allows communication between different documents (in different windows, tabs, frames or s) of the same origin. Messages are broadcasted via a message event fired at all BroadcastChannel objects listening to the channel, except the object that sent the message.
Thank you !