document.addEventListener('DOMContentLoaded', function() {
// Select all anchor tags
var links = document.querySelectorAll('a');
// Loop through each link
links.forEach(function(link) {
var url = link.href;
// Check if the link is external
if (url && !url.includes(window.location.hostname)) {
link.setAttribute('target', '_blank');
}
});
});