var sendTargetToFrame = function(){ document.getElementById('appointment-widget').contentWindow.postMessage({"target":location.protocol+"//"+location.host},"https://local.demandforce.com"); }; var iframe = '
' var iframeSrc = "https://local.demandforce.com/b/sujinsmiles/schedule?widget=1"; var d3cp_appt_source; var d3cp_appt_returnpage; iframeSrc = iframeSrc.concat("&legacyWidget=1"); //if d3cp_appt_source is passed in by the business, pass that to our page if(d3cp_appt_source){ iframeSrc = iframeSrc.concat("&appt_source=").concat(d3cp_appt_source); } if( d3cp_appt_returnpage ){ iframeSrc = iframeSrc.concat("&d3cp_appt_returnpage=").concat(d3cp_appt_returnpage).concat("&appt_origin=").concat(location.protocol+"//"+location.host); } document.write(iframe); iframe = document.getElementById("appointment-widget"); iframe.src = iframeSrc; var backLinkContainer = document.createElement("div"); backLinkContainer.setAttribute("style", "color: #888; padding: 10px; font-size: 15px; font-family:HelveticaNeueLight,HelveticaNeue-Light,Helvetica Neue Light,HelveticaNeue,Helvetica Neue,Helvetica,Arial,sans-serif;"); var backLink = 'Provided for ' +"Sujin Smiles DMD LLC" +' by '; backLinkContainer.innerHTML = backLink; iframe.parentNode.appendChild(backLinkContainer); window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { // Check to make sure that this message came from the correct domain. if (event.origin !== "https://local.demandforce.com") { return; } var data = event.data; if(data && data.height) { iframe.setAttribute('height',data.height); } // if URlto is send in the message, the page will redirect to the given URL if(data && data.URLto){ window.location.href = data.URLto; } }