Skip to content

Commit

Permalink
Changed miscellaneous JS function "makeLinksExternal" to detect links…
Browse files Browse the repository at this point in the history
… with the 'href' attribute starting with 'http' (but not being 'https://access-hive.org.au') and add the attribute "target='_blank'".
  • Loading branch information
atteggiani committed Apr 18, 2024
1 parent 73b084e commit ab4d61a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/js/miscellaneous.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,14 @@ function tabFunctionality() {


/*
Add the external-link icon to <a> tags with target="_blank"
Make links that go to a different website 'external' by adding the
target="_blank" attribute, and add an external-link icon to them.
*/
function addExternalLinkIcon() {
let extLinks = document.querySelectorAll("article a[target='_blank']:not(:is(.vertical-card,.horizontal-card))");
function makeLinksExternal() {
let extLinks = document.querySelectorAll("article a[href^='http']:not([href^='https://access-hive.org.au']):not(:is(.vertical-card,.horizontal-card))");
extLinks.forEach(link => {
link.classList.add('external-link');
link.setAttribute('target','_blank');
})
}

Expand Down Expand Up @@ -216,7 +218,7 @@ function main() {
adjustScrollingToId();
tabFunctionality();
sortTables();
addExternalLinkIcon();
makeLinksExternal();
fitText();
toggleTerminalAnimations();
makeCitationLinks();
Expand Down

0 comments on commit ab4d61a

Please sign in to comment.