Last active
March 20, 2019 14:54
-
-
Save bluesmoon/dcef84260b24c9965e8f884f3331ef69 to your computer and use it in GitHub Desktop.
Load boomerang while allowing the caller to control where the iframe is loaded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
if (window.BOOMR && window.BOOMR.version) { return; } | |
var dom,doc,where,iframe = document.createElement("iframe"),win = window; | |
function boomerangSaveLoadTime(e) { | |
win.BOOMR_onload=(e && e.timeStamp) || new Date().getTime(); | |
} | |
if (win.addEventListener) { | |
win.addEventListener("load", boomerangSaveLoadTime, false); | |
} else if (win.attachEvent) { | |
win.attachEvent("onload", boomerangSaveLoadTime); | |
} | |
iframe.src = "javascript:void(0)"; | |
iframe.title = ""; iframe.role = "presentation"; | |
(iframe.frameElement || iframe).style.cssText = "width:0;height:0;border:0;display:none;"; | |
where = document.currentScript document.getElementsByTagName("script")[0]; | |
where.parentNode.appendChild(iframe); | |
try { | |
doc = iframe.contentWindow.document; | |
} catch(e) { | |
dom = document.domain; | |
iframe.src="javascript:var d=document.open();d.domain='"+dom+"';void(0);"; | |
doc = iframe.contentWindow.document; | |
} | |
doc.open()._l = function() { | |
var js = this.createElement("script"); | |
if (dom) { this.domain = dom; } | |
js.id = "boomr-if-as"; | |
js.src = "https://s.go-mpulse.net/boomerang/" + "API-KEY-HERE"; | |
BOOMR_lstart=new Date().getTime(); | |
this.body.appendChild(js); | |
}; | |
doc.write('<body onload="document._l();">'); | |
doc.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment