Skip to content

Commit 8ca8875

Browse files
committed
Adds func externalLinksOpenNewTab() so all hyperlinks open in new tab, preserving app as open.
Signed-off-by: michael vincerra <michael.vincerra@intel.com>
1 parent bc239ad commit 8ca8875

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/docs/_static/script.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ document.addEventListener('DOMContentLoaded', function () {
4848
showTotalRecords();
4949
attachSearch();
5050
filterPaginatedData();
51+
externalLinksOpenNewTab();
5152
lastUpdated();
5253
})
5354
});
@@ -366,3 +367,18 @@ function renderCards(data) {
366367
}
367368
})
368369
}
370+
371+
function externalLinksOpenNewTab() {
372+
373+
const hyperlinks = document.querySelectorAll("a[href^='https://'], a[href^='http://']");
374+
const host = window.location.hostname;
375+
const internalLink = link => new URL(link).hostname === host
376+
377+
hyperlinks.forEach(link => {
378+
if (internalLink(link)) return
379+
link.setAttribute("target", "_blank")
380+
link.setAttribute("rel", "noopener")
381+
})
382+
383+
};
384+

0 commit comments

Comments
 (0)