Skip to content

Instantly share code, notes, and snippets.

@jbinkleyj
Forked from cowboy/awesome.js
Last active August 29, 2015 14:08
Show Gist options
  • Save jbinkleyj/db3681596875d0ad99f1 to your computer and use it in GitHub Desktop.
Save jbinkleyj/db3681596875d0ad99f1 to your computer and use it in GitHub Desktop.
document.write = (function(write){
var override = function() {
if(document.readyState !== "loading") { // document has finished loading - we want to intercept this call to document.write
if (window.ueLogError) {
try {
throw new Error("`document.write` called after page load on the gateway.");
}
catch(e) {
ueLogError(e, { logLevel : 'ERROR', attribution: 'gw-third-party-js' });
}
}
}
else if(write.apply) { // modern browsers
write.apply(document, Array.prototype.slice.call(arguments, 0));
}
else { // old versions of IE
document.write = write;
var args = "";
for(var a=0; a<arguments.length; a++) {
args += (args?",":"")+"arguments["+a+"]";
}
eval("document.write("+args+");");
document.write = override;
}
};
return override;
}(document.write));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment