client-side redirect for device-support section

This commit is contained in:
Daniel Micay 2020-02-14 15:28:36 -05:00
parent a20ebf0779
commit c82909fb50
2 changed files with 23 additions and 0 deletions

View File

@ -114,5 +114,6 @@
<li><a href="https://reddit.com/r/GrapheneOS">Reddit</a></li>
</ul>
</footer>
<script src="/redirect.js?0"></script>
</body>
</html>

22
static/redirect.js Normal file
View File

@ -0,0 +1,22 @@
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT
"use strict";
// Client-side redirects for fragments (anchors)
//
// It should be possible to do this with server-side redirects, but it was never implemented or
// standardized. For reference:
//
// https://www.w3.org/People/Bos/redirect
// https://www.w3.org/Protocols/HTTP/Fragment/draft-bos-http-redirect-00.txt
function handle_hash() {
if (window.location.hash === "#device-support") {
window.location.replace("https://grapheneos.org/faq#device-support");
}
}
handle_hash();
addEventListener("hashchange", handle_hash, false);
// @license-end