Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sysend

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sysend

Send messages to other tabs/windows in the same origin and browser

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
decreased by-49.39%
Maintainers
1
Weekly downloads
 
Created
Source

npm bower

sysend.js

sysend.js is small library that allow to send message between pages that are open in the same browser. They need to be in same domain. The library don't use any dependencies and use HTML5 LocalStorage API or BroadcastChannel API. If your browser don't support BroadcastChannel (see Can I Use) then you can send any object that can be serialized to JSON with BroadcastChannel you can send any object (it will not be serialized to string). You can also send empty notification.

Tested on:

GNU/Linux: in Chromium 34, FireFox 29, Opera 12.16 (64bit)
Windows 10 64bit: in IE11 and Edge 38, Chrome 56, Firefox 51
MacOS X El Captain: Safari 9, Chrome 56, Firefox 51

Instalation

Include sysend.js file in your html, you can grab the file from npm:

npm install sysend

or bower

bower install sysend

you can also get it from unpkg.com CDN

Usage


window.onload = function() {
    sysend.on('foo', function(message) {
        console.log(message);
    });
    var input = document.getElementsByTagName('input')[0];
    document.getElementsByTagName('button')[0].onclick = function() {
        sysend.broadcast('foo', {message: input.value});
    };
};

Demo

Open this demo page in two tabs/windows

The demo also use iframe proxy to send message to different domain (on firefox you need to add CORS for the iframe see Cross-Domain LocalStorage)

API

sysend object:

  • on(name, callback) - callback(object, name) - add event of specified name
  • off(name [, callback]) - remove callback
  • broadcast(name [, object]) - send object and fire all events with specified name (in different pages that register callback using on). You can also just send notification without object

License

Copyright (C) 2014-2017 Jakub Jankiewicz
Released under the MIT license

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Keywords

FAQs

Package last updated on 21 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc