let eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; let eventer = window[eventMethod]; let messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
//make sure the html id matches the iframe in the getElementById('') //this is used to make sure that the event is coming from where we expect it to. let iframeWindow = document.getElementById('myFrame').contentWindow;
eventer(messageEvent, function(e) { // make sure we are getting the event from the expected source. if (e.source !== iframeWindow) { return; // Not the expected sender }
if (e.data === 'submitted') { // uncomment this section for the redirect let url = "https://www.usmslab.com/thank-you-portal-form/; window.location.href = url;
//scroll to the top. //window.scrollTo(0,0); } else { return; }
},false);