diff --git a/app/views/account/rpiframe.html.erb b/app/views/account/rpiframe.html.erb index 5ecd9e0..9df36ea 100644 --- a/app/views/account/rpiframe.html.erb +++ b/app/views/account/rpiframe.html.erb @@ -21,6 +21,11 @@ window.addEventListener("message", receiveMessage, false); function receiveMessage(e) { + // other scripts might use postMessage method, filter out events + // not originated from opiframe. + var opiframe = window.parent.document.getElementById("opiframe").contentWindow; + if (e.source !== opiframe) { return }; + if (e.origin !== target_origin) { return alert('Wrong target origin: ' + target_origin); } stat = e.data;