tab-emitter
is a client-side javascript module that allows you to send events
between browser tabs/windows. The sending/recieving web pages must have the
same origin.
tab-emitter
is written to work with
browserify, and is extremely easy to
implement in your code. Give it a shot, or if you're not convinced, play with this demo!
Open this site in multiple tabs/windows. Try placing the windows beside each other.
Then, type a color:
var emitter = require('tab-emitter')()
var input = document.querySelector('input')
function setColor(color) {
if (input.value !== color) input.value = color
if (color) document.body.style.backgroundColor = color
}
setColor('white')
emitter.on('color', setColor)
input.addEventListener('keydown', function () {
setTimeout(function () {
emitter.emit('color', input.value)
}, 0)
})