Skip to content

Instantly share code, notes, and snippets.

@iurevych
Created January 29, 2014 10:00
Show Gist options
  • Save iurevych/8684915 to your computer and use it in GitHub Desktop.
Save iurevych/8684915 to your computer and use it in GitHub Desktop.
window.CurebitIntegration = {};
(function() {
CurebitIntegration.receiveMessage = function(callback) {
if (window.addEventListener) {
window.addEventListener("message", callback);
} else {
window.attachEvent("onmessage", callback)
}
};
})();
var curebitOfferDomain = "http://curebit.com",
curebitOfferSrc = curebitOfferDomain + "/o/dideeF/show/#" + encodeURIComponent(document.location.href),
curebitOfferIframe = document.createElement("iframe");
curebitOfferIframe.setAttribute("src", curebitOfferSrc);
curebitOfferIframe.setAttribute("frameborder", "0");
curebitOfferIframe.setAttribute("style", "display: block; height: 100%; left: 0; position: absolute; position: fixed; top: 0; width: 100%; z-index: 99999;");
document.body.appendChild(curebitOfferIframe);
CurebitIntegration.receiveMessage(function(e) {
if (e.data === "curebit_close_offer_popup") {
curebitOfferIframe.parentNode.removeChild(curebitOfferIframe);
}
console.log(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment