biqing / messengerjs Goto Github PK
View Code? Open in Web Editor NEWA common solution for cross-document communication .
Home Page: http://biqing.github.io/MessengerJS/
A common solution for cross-document communication .
Home Page: http://biqing.github.io/MessengerJS/
新版直接用 QC.module 直接导致代码无法执行,感觉很莫名其妙啊……
而且原文档、 Demo 也失效了,请更新一下,谢谢~
平时不用postMessage,主要考虑到的是postMessage发送到其他域信息如果被存储下来,其他页可以onmessage全盘接收保存,不太安全,是否可以在发送一次消息后,获取当前域名,下次发送时,直接指定域名呢,毕竟指定了iframe的名称,通过名称map映射到对应的origin,存储origin再返回给发送发,下次发送时自动带上?更或者初始化target时,自动就做一下origin映射,是否可以?
Messenger.prototype.initListen的方法中有如下代码逻辑:
for(var i = 0; i < self.listenFunc.length; i++){
if (prefix + name === self.prefix + self.name) {
self.listenFunci;
}
}
这里可以把if的判断放到外面吗,针对一个回调时,prefix和name是不变的了吧,应该只要判断一次就可以进行for循环了,而现在这种写法是在每次循环时都要判断一次,有什么深意吗?
请问父子窗口通过JSON string的方式传递消息,对于嵌入的第三方子页面,传递的消息安全性该如何保证?
是否只能通过开发者自行保证,对数据安全性进行严格校验?
谢谢~
TypeError: msg.split is not a function
/MessengerJS/demo/messenger.js:83
prefix = projectName.toString() || prefix;
new Messenger()的时候,不传入projectName, 会在undefined上面调用函数,导致报错。
网站的demo,能用最新的js文件吗?保持同步,有问题就能看出来了
在parent或者iframe页面里加了:
document.domain = 'xxx';
这套方案就不行了...
update the demonstrattion, to show how iframes communicate directly with each other.
您好!在跨iframe有很多情况是对象或者方法的共享,但是目前是传递的字符串的方式,能否直接传递对象,然后对象共享
postMessage或者是navigator都支持直接send object,这里为什么仅仅提供字符串的msg呢?求解惑。
个人比较喜欢直接发送{eventName: 'xxx', data: object} 这种对象。
// 兼容IE 6/7那块
targetFunc(this.prefix + msg, window);
传递的参数跟上面this.target.postMessage(this.prefix + '|' + this.name + 'Messenger' + msg, '*');不一致,
但是监听处理那块msg.split('Messenger');还是以用了Messenger这个字符做分割,导致ie6不行。。
messenger.addTarget(window.parent.frames[1], 'iframe2');
window.parent.frames[1]这个貌似报错。。。
请问这个支持iframe元素向父元素通信吗?
如题
报错msg.split is not a function
我看了demo,是主域名和二级域名之间的跨域,不知道能不能跨大域,两个不同域名间能使用么?
比如有两个方法:share('jsonstring'),like('jsonstring'),请问,监听调用的时候,如何区分具体调用哪个方法?
这个有办法支持ie5吗?以前的老系统,需要扩展,无奈啊。。。
大神,有没有办法?
我用一个click事件去触发数据变化,每点一次都会增加一次监听,返回的数据也主次增加
messenger传递的消息基于字符串,当参数的值为函数时该如何处理,谢谢!
msg不能为数字,否则剥离了默认的消息前缀后,数字参数不能被调用
不然就要修改源码了…
hi,我在一个jsp页面用messager广播一个消息,在另外一个jsp页面用messager监听消息
在纯html页面没有发生上述问题。
浏览器:FF 32.0.3。Chorme 35.0.1916.153
联系方式:[email protected]
为什么官方demo在真实的IE7下 无法通信,求解!!!
IE8+:
this.target.postMessage(this.prefix + '|' + this.name + 'Messenger' + msg, '*');
ie6\7
targetFunc(this.prefix + msg, window);
应改为:
//原版这里有个BUG,按照ie8+以及现代浏览器的消息格式传入
targetFunc(this.prefix + '|' + this.name + 'Messenger' + msg, window);
这个和store.js简直就绝配,比鬼道写的那个设计好
浏览器QQ7.7.3, 切换至IE8模式下,
此处代码:
Target.prototype.send = function(msg){
this.target.postMessage(this.prefix + '|' + this.name + 'Messenger' + msg, '*');
会出现,script70 没有权限。
在IE8浏览器下是正常的!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.