generated from Web-Development-Environments-2021/Assignment2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
about.js
41 lines (32 loc) · 979 Bytes
/
about.js
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
// Get the modal
var modal = document.getElementById("About");
// Get the button that opens the modal
var btn = document.getElementById("buttomAbout");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
var default_keys=[33,34,35,36,37,38,39,40];
document.addEventListener('keydown', function(e) {
var key = e.which;
if(default_keys.includes(key)) {
e.preventDefault();
return false;
}
if (key == 27){
modal.style.display = "none";
}
return true;
});