Skip to content

Instantly share code, notes, and snippets.

@vhmolinar
Created May 19, 2020 18:08
Show Gist options
  • Save vhmolinar/f9b64044fd912935ece5fc39c9602b3f to your computer and use it in GitHub Desktop.
Save vhmolinar/f9b64044fd912935ece5fc39c9602b3f to your computer and use it in GitHub Desktop.
Html redirect example
<head>
<link rel="canonical" href="https://yourlink.com"/>
<noscript>
<meta http-equiv="refresh" content="0;URL=https://yourlink.com">
</noscript>
<!--[if lt IE 9]><script type="text/javascript">var IE_fix=true;</script><![endif]-->
<script type="text/javascript">
var url = "https://yourlink.com";
if(typeof IE_fix != "undefined") // IE8 and lower fix to pass the http referer
{
document.write("redirecting..."); // Don't remove this line or appendChild() will fail because it is called before document.onload to make the redirect as fast as possible. Nobody will see this text, it is only a tech fix.
var referLink = document.createElement("a");
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
}
else { window.location.replace(url); } // All other browsers
</script>
<!-- Credit goes to http://insider.zone/ -->
<!-- REDIRECTING ENDS -->
</head>
@vhmolinar
Copy link
Author

Replace https://yourlink.com by your own address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment