监视 iframe 中的消息
Watching for a message in an iframe
我想知道 JavaScript/AngularJS 中是否有一种方法可以在消息出现在 iframe 中时从本质上查找某种消息。例如,我在 iframe 中有一个表单,我完成了该表单,它告诉我我已经完成了,有没有办法通过 JS 检测到它?
任何 help/suggestions 将不胜感激。
外部 iframe 监听事件
window.addEventListener( "message",
function (e) {
alert(e.data);
},false);
在 iframe 内触发事件
window.postMessage('form complete');
我想知道 JavaScript/AngularJS 中是否有一种方法可以在消息出现在 iframe 中时从本质上查找某种消息。例如,我在 iframe 中有一个表单,我完成了该表单,它告诉我我已经完成了,有没有办法通过 JS 检测到它?
任何 help/suggestions 将不胜感激。
外部 iframe 监听事件
window.addEventListener( "message",
function (e) {
alert(e.data);
},false);
在 iframe 内触发事件
window.postMessage('form complete');