-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (55 loc) · 1.3 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
<!DOCTYPE html>
<html>
<head>
<title>Javascript Slideshow</title>
<style>
.mySlides {display:none;}
</style>
</head>
<body>
<h2 class="w3-center">Javascript Handled Slideshow</h2>
<div class="w3-content w3-section" style="max-width:500px">
<img class="mySlides" style="width:100%">
<img class="mySlides" style="width:100%">
<img class="mySlides" style="width:100%">
<img class="mySlides" style="width:100%">
<img class="mySlides" style="width:100%">
</div>
<script>
var myIndex = 0;
var seconds=0;
imagetime();
function carousel() {
var i;
var imagearray=["img1.jpg",
"img2.jpg",
"img3.jpg",
"img4.jpg",
"img5.jpg"]
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
x[i].src=imagearray[i];
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, seconds);
}
function imagetime()
{
seconds = parseInt(prompt("Provide image vieweing time in seconds", ));
seconds=seconds*1000;
if(isNaN(seconds))
{
alert("make sure to provide a correct number for slider to display")
imagetime()
}
else
{
carousel()
}
}
</script>
</body>
</html>