initial public commit
This commit is contained in:
12
dist-demo/demo/external-links.js
Normal file
12
dist-demo/demo/external-links.js
Normal file
@@ -0,0 +1,12 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const currentHost = window.location.hostname;
|
||||
|
||||
const links = document.querySelectorAll("a");
|
||||
|
||||
links.forEach((link) => {
|
||||
if (link.hostname && link.hostname !== currentHost) {
|
||||
link.setAttribute("target", "_blank");
|
||||
link.setAttribute("rel", "noopener noreferrer");
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user