diff --git a/src/docs/_static/script.js b/src/docs/_static/script.js index 91cbdc0344..722f5bfa9c 100755 --- a/src/docs/_static/script.js +++ b/src/docs/_static/script.js @@ -48,6 +48,7 @@ document.addEventListener('DOMContentLoaded', function () { showTotalRecords(); attachSearch(); filterPaginatedData(); + externalLinksOpenNewTab(); lastUpdated(); }) }); @@ -366,3 +367,18 @@ function renderCards(data) { } }) } + +function externalLinksOpenNewTab() { + + const hyperlinks = document.querySelectorAll("a[href^='https://'], a[href^='http://']"); + const host = window.location.hostname; + const internalLink = link => new URL(link).hostname === host + + hyperlinks.forEach(link => { + if (internalLink(link)) return + link.setAttribute("target", "_blank") + link.setAttribute("rel", "noopener") + }) + +}; +