make external links open in new tab

This commit is contained in:
timurgordon
2022-08-25 14:09:11 +03:00
parent 18a96f0adc
commit 22a94bfe70
4 changed files with 4374 additions and 9 deletions

View File

@@ -22,6 +22,19 @@
// Insert Twitter Pixel ID and Standard Event data below
twq('init', 'o745b');
twq('track', 'PageView');
// makes all links outside of hostname open in new tab
// from: https://stackoverflow.com/a/4425214
var links = document.links;
console.log(links)
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].target = '_blank';
}
}
</script>
<!-- End Twitter universal website tag code -->