Add externallinks.js
This commit is contained in:
parent
fe175e7ebd
commit
0b391bf37f
1 changed files with 9 additions and 0 deletions
9
externallinks.js
Normal file
9
externallinks.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
var links = document.querySelectorAll('a[href^="https://"], a[href^="http://"]');
|
||||||
|
links.forEach(function(link) {
|
||||||
|
if (!link.href.includes(window.location.hostname)) {
|
||||||
|
link.setAttribute('target', '_blank');
|
||||||
|
link.setAttribute('rel', 'noopener noreferrer');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue