forked from WangJia-mm/JavaScript201708
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-eventKey.html
More file actions
29 lines (29 loc) · 790 Bytes
/
2-eventKey.html
File metadata and controls
29 lines (29 loc) · 790 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>珠峰培训</title>
<link rel="stylesheet" href="css/reset.min.css">
<style>
html, body {
width: 100%;
height: 1000%;
background: -webkit-linear-gradient(top left, lightblue, lightcoral);
}
</style>
</head>
<body>
<script>
//=>禁止F5刷新(默认行为)
document.onkeydown = document.onkeypress = document.onkeyup = function (e) {
e = e || window.event;
var keyNum = e.which || e.keyCode;
if (keyNum === 116) {
//->F5
e.keyCode = 0;//->IE下还需要把KEY-CODE设置为零才管用
e.preventDefault ? e.preventDefault() : e.returnValue = false;
}
}
</script>
</body>
</html>