Skip to content

Instantly share code, notes, and snippets.

@anthonysbrown
Last active Aug 29, 2015
Embed
What would you like to do?
Javascript Linkout Script Using Colorbox
<div style="display:none">
<div class="dove-tail-linkout-content">
<p>You are currently leaving the site! please confirm you would like to leave</p>
</div>
</div>
(function( $ ){
$.fn.dovetailLinkout= function(linkout){
if(
linkout.hasClass('safe_link') ||
linkout.parent().hasClass('safe_link') ||
linkout.attr('href') == '' ||
linkout.attr('href').substring(0, 1) == "#" ||
linkout.attr('href').substring(0, 10) == "javascript"
){
return true;
}else{
$.colorbox({width:"450px", height:"400px",html: '<div class="colorbox-linkout-modal">' + $('.dove-tail-linkout-content').html()+ '<div class="colorbox-linkout-button"><a href="' + linkout.attr('href') +'" class="force_link">Click here to proceed to ' + linkout.attr('href') +'</a></div></div>'});
return false;
}
}
})( jQuery );
jQuery( document ).ready(function($) {
$('a').each(function () {
if (this.host.replace(':443','') !== location.host &&this.host.replace(':80','') !== location.host) {
$(this).addClass('external_link');
}
else {
$(this).addClass('internal_link');
}
});
$('a.external_link').on('click',function(e){e.preventDefault(); return $(this).dovetailLinkout($(this)); });
$('a.external_link span').on('click',function(e){e.preventDefault(); return $(this).dovetailLinkout($(this).parent()); });
$('.ubermenu-item').on('click',function(e){e.preventDefault(); return $(this).dovetailLinkout($(this).child()); });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment