Created
May 2, 2016 20:30
-
-
Save chancesmith/d9d7ca1999528005f5a1bac945d33bfa to your computer and use it in GitHub Desktop.
Confirm with user that they are about to leave the current site. (security confirmation for banking industry)
This file contains 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
// hide all mailto links and gform anchors from external link checker | |
$('a[href^="mailto:"]').addClass('remove-arrow'); | |
$('a[href^="tel:"]').addClass('remove-arrow'); | |
$('.staff a').addClass('remove-arrow'); | |
$('a.gform_anchor').addClass('remove-arrow'); | |
$('.calc.modal a').addClass('remove-arrow'); | |
$('.cta-slim .btn a').addClass('remove-arrow'); | |
//check for external links | |
function link_is_external(link_element) { | |
return (link_element.host !== window.location.host); | |
} | |
$('a').each(function() { | |
if ( $(this).hasClass('remove-arrow') ) { | |
// nada | |
} else { | |
if (link_is_external(this)) { | |
// show the link is extrenal | |
$(this) | |
.append(' <i class="fa fa-external-link"></i>') | |
.addClass('external-link'); | |
} | |
} | |
if (link_is_external(this)) { | |
// all links that are external get confirmed (except elements with .no-speed-bump) | |
if ( $(this).hasClass('no-speed-bump') ) { | |
// nada | |
} else { | |
$(this).attr('target', '_blank'); | |
$(this).attr('onClick', 'var m = "You are leaving Foundation Bank: " + $(this).attr("href"); return confirm(m);'); | |
} | |
} | |
}); | |
// confirm on external link click | |
function confirmExternalLink(item){ | |
var url = $(item).attr('href'); | |
var m = "You are leaving Foundation Bank: " + $(item).attr('href'); | |
var r = confirm(message); | |
if (r == true) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment