Skip to content

Instantly share code, notes, and snippets.

@chrismauck
Last active April 21, 2017 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismauck/163469b580e5b293239b93356fe5003c to your computer and use it in GitHub Desktop.
Save chrismauck/163469b580e5b293239b93356fe5003c to your computer and use it in GitHub Desktop.
DoubleClick Exit
/*
* addExit - Add DoubleClick exit
*
* @param {String | Array} el - id, or array of element ids to accept the event
* @param {String} evt - event to listen for
* @param {String} ext - name of the DoubleClick exit
* @param {String} alt - URL of DoubleClick exit override if exists
* Usage addExit.event('cta', 'click', 'Main Exit');
*/
var addExit = {
event: function( el, evt, ext, alt ) {
if(typeof el === 'string') {
var ele = document.getElementById(el);
ele.addEventListener(evt, function(){ addExit.exit( ext, alt ); }, false);
} else if (Array.isArray(el)) {
for (var j=0, len = el.length; j < len; j++) {
var ele = document.getElementById(el[j]);
ele.addEventListener(evt, function(){ addExit.exit( ext, alt ); }, false);
}
}
},
exit: function( ext, alt ) {
return ( alt ) ? Enabler.exit(ext, alt) : Enabler.exit(ext);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment