-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredirect.html
56 lines (56 loc) · 2.11 KB
/
redirect.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="author" content="Parashuram">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="MSSmartTagsPreventParsing" content="true">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" href="https://nparashuram.com/favicon.ico">
<link rel="image/vnd.microsoft.icon" rel="icon" href="https://nparashuram.com/favicon.ico">
<meta name="theme-color" content="#fff">
<link rel="icon" sizes="369x369" href="http://nparashuram.com/me.png">
<title>Redirecting ... </title>
</head>
<body style="text-align:center">
<div id="redirect">
<h1 id="timer">Redirecting in 5 ... </h1>
<h2><span id="destination"></span></h2>
<hr />
</div>
<div>
<button id="set_redirect">Set Redirect URL</button>
<button id="cancel_timer">Cancel Redirect</button>
</div>
<script type="text/javascript">
var redirect = window.localStorage['redirect_page'];
var time = 5;
var timerEl = document.getElementById("timer");
var timer = null;
if (typeof redirect === "undefined") {
document.getElementById("redirect").style.display = "none";
} else {
document.getElementById("destination").innerText = redirect + window.location.search
var timer = window.setInterval(function() {
timerEl.innerText = "Redirecting in " + time--;
if (time < 0) {
window.clearInterval(timer);
window.location.href = redirect + window.location.search;
}
}, 1000)
}
document.getElementById("cancel_timer").addEventListener("click", function() {
timerEl.innerText = "Redirect cancelled";
window.clearInterval(timer);
});
document.getElementById("set_redirect").addEventListener("click", function() {
redirect = window.prompt("Redirect URL", redirect)
if (redirect) {
window.localStorage['redirect_page'] = redirect
window.location.reload()
}
});
</script>
</body>
</html>