-
-
Save softplus/28ab8b3357c240786c1fc10229ced529 to your computer and use it in GitHub Desktop.
Nofollow bounce page (Markdown, HTML, JS)
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
Click here to follow this link: | |
<span id="redirect"></span> | |
<script type="text/javascript"> | |
// Take any URL after the # and redirect to it, if the referrer is local. | |
// For visitors without a local referrer, just display the link and let them click. | |
let target = document.location.hash.substring(1); | |
if (target && (target.startsWith("http://") || target.startsWith("https://"))) { | |
if (document.referrer.startsWith(document.location.origin)) { | |
// we can redirect | |
document.location=target; | |
} else { | |
// just display the link | |
let el = document.createElement("a"); | |
el.href = target; | |
el.rel = "nofollow"; | |
el.className = "external"; | |
el.target = "_blank"; | |
el.appendChild(document.createTextNode(target)); | |
document.getElementById("redirect").appendChild(el); | |
} | |
} else { | |
// no target | |
document.getElementById("redirect").innerHTML = "none"; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment