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

arale-messenger

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arale-messenger

跨域 Iframe 通信解决方案,兼容 IE 系列浏览器。

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Messenger


Build Status

跨域 Iframe 通信解决方案,兼容主流和 IE 系列浏览器。


Usage

父页面

// 初始化父页面的信使
var messenger = new Messenger('parent', 'MessengerProject');

// 绑定子页面 iframe
messenger.addTarget(iframe1.contentWindow, 'iframe1');
messenger.addTarget(iframe2.contentWindow, 'iframe2');

// 给子页面发消息
messenger.targets['iframe1'].send('发给子页面1的消息');

// 或者给所有子页面发消息
messenger.send('发给所有子页面的消息');

子页面

// 初始化子页面的信使
// 注意,第二个参数 `MessengerProject` 必须和父页面的信使保持一致,
var messenger = new Messenger('iframe1', 'MessengerProject');

// 给父页面发消息
messenger.targets['parent'].send('发给父页面的消息');

感谢

本组件源码来自 https://github.com/biqing/MessengerJS

文档亦可参考 biqing/MessengerJS

Keywords

FAQs

Package last updated on 23 Dec 2015

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