Hirrolot / hirrolot.github.io

My blog
https://hirrolot.github.io/
8 stars 1 forks source link

JS-less redirection #7

Closed jakwings closed 2 years ago

jakwings commented 2 years ago

Thanks for your good writings! I stumbled over this article with NoScript prohibiting javascript, thus an empty page was shown (even without a <title>): https://hirrolot.github.io/posts/barebones-lambda-cube-in-ocaml.html

Hereby I suggest this template for you:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv='refresh' content="0; url=https://github.com/hirrolot"/>
  </head>
  <body>
    <script>window.location.assign("https://github.com/hirrolot");</script>
    <noscript><a href="https://github.com/hirrolot">https://github.com/hirrolot</a></noscript>
  </body>
</html>
Hirrolot commented 2 years ago

Thanks! But why do we need a JS redirect in <body> in the presence of http-equiv='refresh'?

Hirrolot commented 2 years ago

Then a notice with "Allow" button would show up.

Why isn't it fine? (Sorry, I'm not a front-end dev, may ask stupid questions.)

Hirrolot commented 2 years ago

Apparently, according to css-tricks.com, the method with http-equiv='refresh' is discouraged to use at all:

Although this method is the easiest way to redirect to a web page there are a few disadvantages. According to the W3C there are some browsers that freak out with the Meta refresh tag. Users might see a flash as page A is loaded before being redirected to page B. It also disables the back button on older browsers. It’s not an ideal solution, and it’s discouraged to use at all.

So instead I implemented proper redirect pages with a title and a human-readable redirect notice when the NoScript extension is turned on.