Hi, I want that all links open in a new tab, instead of editing those every single time.
Can I use the script:
function autoblank() { var links = document.links; for (let i = 0, linksLength = links.length ; i < linksLength ; i++) { if (links[i].hostname !== window.location.hostname) { links[i].target = '_blank'; links[i].rel = 'noopener noreferrer'; // This is for security purposes } } } autoblank();
is it correct and Should I add it to my footer.php ? Is there a better option than that? Thank you!
Hi, I want that all links open in a new tab, instead of editing those every single time.
Can I use the script:
function autoblank() {
var links = document.links;
for (let i = 0, linksLength = links.length ; i < linksLength ; i++) {
if (links[i].hostname !== window.location.hostname) {
links[i].target = '_blank';
links[i].rel = 'noopener noreferrer'; // This is for security purposes
}
}
}
autoblank();
is it correct and Should I add it to my footer.php ? Is there a better option than that? Thank you!
Hi,
You can install & use the Open Links In New Tab plugin here: https://wordpress.org/plugins/open-links-in-new-tab/
Regards,
PenciDesign.
Thank you!