var espEventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; var espEventer = window[espEventMethod]; // Now... // if // "attachEvent", then we need to select "onmessage" as the event. // if // "addEventListener", then we need to select "message" as the event var espMessageEvent = espEventMethod == "attachEvent" ? "onmessage" : "message"; // Listen to message from child IFrame window espEventer(espMessageEvent, function (event) { if (event.data==='gotoTop') { //window.scroll(0,0); /*$('html, body').animate({ scrollTop: 0 }, 500);*/ //consolevent.log("Gototop"); var element = document.getElementById("intrasSignupFormFrame"); //top += element.offsetTop boundingRect = element.getBoundingClientRect(); if (boundingRect) { window.scrollBy(0, boundingRect.top-100); // Scroll 100px to the right } /*if (!!e && e.scrollIntoView) { e.scrollIntoView(); } */ } else { // komando:værdi /*console.log("TEST"); console.log(event.data) ; console.log("TEST END");*/ if (!event.data.split) return false; tmpArr = event.data.split(":"); if (tmpArr[0]=='winHeight') { espframe = document.getElementById("intrasSignupFormFrame"); if (espframe) { newHeight = (parseInt(tmpArr[1]) + 100); if (newHeight>200) { espframe.style.height = newHeight + 'px'; } } } // Hvis der ikke er registreret en cookie i privat framen, så kaldes dette - for at omgå bookmarkede #cookieSet if (1==2 && tmpArr[0]=='fixCookies') { /*var div2 = document.createElement("div"); div2.innerHTML = "####"; document.getElementsByTagName('body')[0].appendChild(div2);*/ /*console.log("redirect"); console.log(window.location.hash);*/ if (window.location.hash=='') { top.location.href='//.energisparepartner.dk/safari-cookie-fix.php'; } else { } } } }, false);