generated from cloud-gov/pages-uswds-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from GSA/staging
OGPWEB-10753 External links now displays the external link icon beside them and opens a new window
- Loading branch information
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
// Add your custom javascript here | ||
console.log("Hi from Federalist"); | ||
|
||
|
||
document.addEventListener('DOMContentLoaded', function() { | ||
const links = document.querySelectorAll('a'); | ||
links.forEach(link => { | ||
const url = new URL(link.href); | ||
if (url.origin !== window.location.origin && !link.querySelector('img')) { | ||
link.classList.add('external-link'); | ||
link.setAttribute('target', '_blank'); | ||
} | ||
}); | ||
}); |