.

How to use Welpike's redirect.js file? - by Welpike

First : include this script in your <head>.

<script src="https://welpike.github.io/url/api/redirect.js"></script>

Secondary : create a script (file or in <script>) after the script include tag.

let url = "https://welpike.github.io/url/docs.html"; // define the url
delay = 5; // define the time before the redirecting (in seconds)
redirect(url, delay); // call function

It's finish.

Test

Test the script : test >>

Source code of the test page : https://github.com/Welpike/url/blob/master/docs-test.html

How does it works ?

redirect.js uses window.location.replace().

Please show this tag somewhere in the <body> of the file who redirects your users.

<p style="font-family:monospace;">Redirect powered by <a href="https://welpike.github.io/" target="_blank">welpike.github.io</a></p>

For the back-end developers using frameworks (like django), a new update plans that the redirect.js script recovers the domain name.
Instead of code this let url = "http://127.0.0.1:8000/{% url 'login' %}"; (e.g.), you can write this : let url = domain + "{% url 'login' %}";.

Welpike

Other docs :