I have a pop-up link that detects if its a external link. The pop-up is able to detect if there is a external link correctly.
The website is using Mura CMS which users have used a feature in Mura to create links within Mura (click here). This is a problem do to users creating Mura links that have external links and the logic in play is unable to detect whether the link is internal or external.
The following is the logic being used to detect external links:
$("a:not('.frontEndToolsModal')").on('click', function(e){
e.preventDefault();
var url = $(this).attr('href'),
host = location.host;
if (url.indexOf(host) > -1 || url.indexOf('http','https') == -1){
/* If we find the host name within the URL,
OR if we do not find http or https,
meaning it is a relative internal link.
The following statements is to not interefere with Mura CMS front end tools
*/
if(url.indexOf('/admin/?muraAction=cArch.list') == 0){
var newTab = window.open(url, '_blank');
newTab.focus();
}
else if(url.indexOf('/admin/?muraAction') == 0){
//do nothing
}else{
window.location.href = url;
}
}else {
var m = modal.open({content: "POP UP MESSAGE"});
if(m == true) {
return m;
}
}
});
My question is: How can I detect whether the Mura link created contains a internal or external link?