项目
在 GitHub 查看
krasimir/lsbridge
关于
将本地存储用作通信通道
其他项目实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文The Local Storage Bridge
1K library for exchanging messages between tabs in a same browser. It uses the local storage as a communication channel.
The story behind the library is available here.
Usage
Add lsbridge.min.js to your page:
<script src="js/lsbridge.min.js"></script>
There is a global object lsbridge available.
Send messages:
lsbridge.send('my-namespace', { message: 'Hello world!' });
Listen for messages:
lsbridge.subscribe('my-namespace', function(data) {
console.log(data); // prints: { message: 'Hello world!'}
});
Find out if localStorage is available:
console.log(lsbridge.isLSAvailable); // prints "true" or "false"
Cancel listeners for specific namespace:
lsbridge.unsubscribe('my-namespace');
Compilation
- Run
npm installto get UglifyJS installed. - Run
npm run-script compileto producebuild/jsbridge.min.js
Example
Try it yourself by opening example/index.html in a browser.

探索相关项目
加载中…