-
Notifications
You must be signed in to change notification settings - Fork 6
/
prerender.html
70 lines (66 loc) · 2.19 KB
/
prerender.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
<!DOCTYPE html>
<html>
<!--<link rel="prerender" href="https://www.youtube.com/watch?v=UcVnorMPix8">-->
<!--<link rel="prerender" href="https://bokand.github.io/slowscroller.html">-->
<!--<a href="https://news.ycombinator.com">HackerNews PRERENDER</a>-->
<head>
<script>
//addEventListener('load', () => {
// const params = new URLSearchParams(window.location.search);
// if (params.has('prerender')) {
// const prerender_url = params.get('prerender');
// console.log("Triggering prerender of: " + prerender_url);
// let rules = document.createElement('script');
// rules.setAttribute('type', 'speculationrules');
// const content =
// `{
// "prerender":[
// {
// "source": "list",
// "urls": ["${prerender_url}"]
// }
// ]
// }`;
// rules.innerHTML = content;
// document.head.appendChild(rules);
// }
//});
</script>
<script type="speculationrules">
{
"prerender":[
{
"source": "list",
"urls": ["https://bokand.github.io/prerender-inner.html"]
}
]
}
</script>
</head>
<body>
<a href="https://bokand.github.io/prerender-inner.html">Prerender Inner</a>
<br>
<br>
<a href="https://airhorner.com">AirHorner!</a>
<br>
<br>
<a href="https://www.youtube.com/watch?v=UcVnorMPix8">YouTube</a>
<br>
<br>
<button id="btn">Alert And Redirect</button>
<script>
//document.getElementById('btn').addEventListener('click', () => {
//setTimeout(() => { console.log("NAV"); window.location = 'https://reddit.com'; }, 20);
//window.location = 'https://reddit.com';
//alert('You can checkout any time you like, but you can never leave');
//});
if (typeof(document.prerendering) != 'undefined') {
console.log("REGISTERED EVENT");
document.onprerenderingchange = () => {
console.log("FIRED EVENT");
setTimeout( () => { document.body.style.backgroundColor = "red"; }, 2000);
}
}
</script>
</body>
</html>