-
Notifications
You must be signed in to change notification settings - Fork 0
/
js57_1my.html
118 lines (85 loc) · 2.47 KB
/
js57_1my.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!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">
<title>Document</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<style>
section {
width: 550px;
height: 400px;
margin: 0 auto;
transition: 0.3s;
}
section:hover {
filter: brightness(80%);
}
div {
position: relative;
width: 70px;
/* border: solid black; */
}
.material-icons {
font-size: 70px;
color: blanchedalmond;
}
.material-icons:hover {
transition: 1s;
color: aqua;
}
#prev {
top: -250px;
}
#next {
top: -330px;
left: 475px;
}
</style>
</head>
<body>
<section id="sec" onmouseout="timerId = setTimeout(changePic, 2000);">
<a id="h1" href="https://www.belarus.by/ru//"><img id="pic" src="images/img1b.jpg" alt=""></a>
<div id="prev"><a href="javascript:bc()"><span class="material-icons">navigate_before</span></a></div>
<div id="next"><a href="javascript:fr()"><span class="material-icons">navigate_next</span></a></div>
</section>
<script>
let n = 1;
let p = 6;
// массив:
to = ['https://ru.wikipedia.org/', 'https://airport.by/', 'https://gorshochek.by/', 'http://beegood.by/', 'https://www.hotelminsk.by/', 'https://www.ya.ru'];
function fr() {
// alert('hello');
if (n == 6) n = 1
else {pic.src = `images/img${n}b.jpg`;
h1.href = to[n-1];
n++;
console.log(pic.src);
}
}
function bc() {
if (n == 1) n = 6
else {pic.src = `images/img${n}b.jpg`;
h1.href = to[n-1];
n--;
console.log(pic.src);
}
}
function changePic() {
if (n > p) n=1;
pic.src = `images/img${n}b.jpg`;
h1.href = to[n-1];
n++;
timerId = setTimeout(changePic, 2000);
}
function stop() {
clearTimeout(timerId);
}
addEventListener('load', changePic);
sec.addEventListener('mouseover', stop);
// sec.addEventListener('mouseout', changePic); не работает
</script>
</body>
</html>