前端iframe父子窗口间通信
【摘要】 iframe或者<object data="xxx" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:773px;width:981px;top:0px;left:0px;right:0px;bottom:0px"> <embed src="xxx" style="overflow:hidden;ove...
iframe或者 <object data="xxx" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:773px;width:981px;top:0px;left:0px;right:0px;bottom:0px"> <embed src="xxx" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:773px;width:981px;top:0px;left:0px;right:0px;bottom:0px"> </object>
父子windows之间通讯:
父窗口中:
function communicator() { this.receiveMessage = function(event) { //alert(event.data.name); var eventData = event.data; switch(eventData.name) { case 'ActionA': ActionA(); break; case 'ActionB': ActionB(); break; default: break; } }; this.sendMessage = function(iFrameElem, message) { iFrameElem.contentWindow.postMessage(message, '*'); }; this.addListeners = function() { window.addEventListener("message", jQuery.proxy(this.receiveMessage, this), false); }; }; var c = new communicator(); c.addListeners();
子窗口中:
window.parent.postMessage({name: 'ActionA'}, '*')
参考:
communicate-iframe-parent-window
https://github.com/ternarylabs/porthole
https://gist.github.com/pbojinov/8965299
https://blog.csdn.net/fdipzone/article/details/17619673
Axure添加自定义js代码
简单的可以使用这种:
javascript:void(alert('请至少选择一项!'))
复杂的可以采用:
javascript:eval('function ....');void(0);
参考:https://zhuanlan.zhihu.com/p/25305935
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)