This repository has been archived by the owner on Aug 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
executable file
·79 lines (59 loc) · 2.68 KB
/
index.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><link is="juicy-redirect"></title>
<link rel="stylesheet" href="http://juicy.github.io/juicy-tile-list/examples/github-markdown.css">
<!-- Importing Web Component's Polyfill (optional, allows to run it in old browsers) -->
<script src="https://cdn.jsdelivr.net/webcomponentsjs/0.7.19/webcomponents.min.js"></script>
<!-- Importing Custom Elements -->
<link rel="import" href="juicy-redirect.html">
<style>
html {
min-height: 100%;
}
body {
padding: 2em;
}
</style>
</head>
<body class="markdown-body">
<a href="https://github.com/Juicy/juicy-redirect"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<h1><link is="juicy-redirect">
<iframe src="http://ghbtns.com/github-btn.html?user=juicy&repo=juicy-redirect&type=watch&count=true&size=medium"
allowtransparency="true" frameborder="0" scrolling="0" width="90" height="30"></iframe></h1>
<p>Custom Element that redirects to a new URL when an attribute is changed.</p>
<p>It can be configured to work using window location or History API.</p>
<p>See <a href="https://github.com/Juicy/juicy-redirect">README.md</a> for docs</p>
<h2>Redirect using <code>window.location</code></h2>
<button id="example1"><link is="juicy-redirect" url="/"></button>
<link is="juicy-redirect" id="redirect1">
<script>
document.getElementById("example1").addEventListener("click", function () {
document.getElementById("redirect1").setAttribute("url", "/");
});
</script>
<h3>Open new tab</h3>
<button id="example1_blank"><link is="juicy-redirect" url="/" target="_blank"></button>
<link is="juicy-redirect" id="redirect1_blank" target="_blank">
<script>
document.getElementById("example1_blank").addEventListener("click", function () {
document.getElementById("redirect1_blank").setAttribute("url", "/");
});
</script>
<h2>Redirect using History API (<code>history.pushState</code>)</h2>
<p>Watch console entries for events logging</p>
<button id="example2"><link is="juicy-redirect" history url="/"></button>
<link is="juicy-redirect" history id="redirect2">
<script>
document.getElementById("example2").addEventListener("click", function () {
document.getElementById("redirect2").setAttribute("url", "/");
});
</script>
<script>
window.addEventListener("juicy-redirect-pushstate", function (e) {
console.info("`juicy-redirect-pushstate` triggered with", e.detail, location.href)
});
</script>
</body>
</html>