forked from Gamer-Guy12/Slide-Show-HTML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (39 loc) · 1.54 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="styles.css" />
<title>Slideshow</title>
</head>
<body>
<script>
document.addEventListener('keydown', (event) => {
var key = event.code;
if (key === "ArrowLeft") {prevSlide()}
else if (key === "ArrowRight") {nextSlide()}
}, false)
var currentId = 0;
var maxId = 0;
function nextSlide() {
if (currentId == maxId) {currentId = 0;}
else {currentId = currentId + 1}
}
function prevSlide() {
if (currentId == 0) {currentId = maxId}
else {currentId = currentId - 1}
}
var interval = setInterval(() => {
for (let i = 0; i <= maxId; i++) {
var img = document.getElementById(i.toString());
img.style.opacity = 0;
if (i === currentId) {img.style.opacity = 1;}
}
}, 100)
</script>
<iframe id="0" class="slide" src="Pages/Title.html">You don't work</iframe>
<button onclick="nextSlide()" class="leftButton noStyle"></button>
<button onclick="prevSlide()" class="rightButton noStyle"></button>
</body>
</html>