Created
May 4, 2021 03:41
-
-
Save helart/99bbd9702b5d15069c620a3f54a60747 to your computer and use it in GitHub Desktop.
target-blank
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
<a href="document.html" rel="ext">в новое окно</a><br /> | |
<script> | |
function externalLinks() { | |
if (!document.getElementsByTagName) return; | |
var anchors = document.getElementsByTagName("a"); | |
for (var i=0; i < anchors.length; i++) { | |
if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "ext") { | |
anchors[i].target = "_blank"; | |
} | |
} | |
} | |
window.onload = externalLinks; | |
</script> | |
<a href="link" onclick="this.target='_blank'">способ 2</a><br /> | |
<a href="link" onclick="return !window.open(this.href)">способ 3</a><br /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment