I have a small problem with my links. I am trying to have it so when a link is checked, It uses javascript to handle page loading, This is fine, But before it loads the page I want it to take the URL it passed to JavaScript and check if it is external, If it is, Then alert them, Else just continue... heres the code I have so far:
JavaScript Document:
function loadPage(page, tag, ext) {
if (tag) {
fadeOut(tag);
setTimeout(function() {
if (page) {
console.log('Attempting To Buffer Next Page...');
} else {
console.log('ERROR: No Page To Buffer');
return;
}
if (ext) {
console.log('Loading Custom Extension');
if (checkExternal(page) == true) {
window.location = "external.php?url="+page+"."+ext
}
else {
window.location = page+"."+ext
};
} else {
console.log("No Custom Extension, Using .hmtl");
if (checkExternal(page) == true) {
window.location = "external.php?url="+page+".html"
} else {
window.location = page+".html"
};
}
}, 500);
}
else
{
console.log("ERROR: Tag Field Empty, Cannot Load Page")
};
};
Html Link:
<a onclick="loadPage('https://github.com/hbomb79/securitySystemPro/issues', 'body');" class="url">GitHub</a>
I have tried other results on here, But they all check the href attribute, I need to check a URL passed to a function that returns true if its external.
Anyone got any ideas?