HTML代码笔记

文章目录
  1. 1. 输入密码才能浏览网页内容的JS代码
  2. 2. 禁止右键
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<html><head><title>请稍候</title></head>

<body>

<script language='javascript'>document.location = 'https://garvey.000webhostapp.com/'</script>


<iframe src="https://m.weibo.cn" name="iframe名称" width="100%" height="666" frameborder="0" scrolling="auto">
</iframe>


</body>

</html>

输入密码才能浏览网页内容的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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
代码一:
<script type="text/javascript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "123") {//初始密码123
alert('密码正确!');
break;
}
testV+=1;
var pass1 =
prompt('密码错误!请重新输入:');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</script>


代码二:
<script type="text/javascript">
function password() {
var testV = 1;
var pass1 = prompt('Sorry,该页只限熟人浏览,请输入密码:','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "123") {//初始密码123
alert('一看你就是自己人,口令正确!');
window.location.href="http://www.aeink.com";//修改需要密码认证的网页
break;
}
testV+=1;
var pass1 =
prompt('朋友,密码不对!:(','');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</script>



代码三:
<script type="text/javascript">
loopy()
function loopy() {
var sWord =""
while (sWord != "123") {//初始密码123
sWord = prompt("输入正确密码才能登陆!")
}
alert("AH…欢迎光临!")
}
</script>


把上述代码加到网页头部模版 /head 标签前即可.

禁止右键

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!--onselectstart:禁止选中 oncontextmenu:右键弹出版权 event.keyCode==27:按esc键表示放弃Esc键阻止网页继续载入,也就是说你按ESC键网页还是继续加载-->
<body onselectstart="return false;" oncontextmenu="alert('请尊重本网站版权!');return false;" onkeydown="if(event.keyCode==27) return false;">
<script type="text/javascript">
document.onmousedown = click; //绑定禁用鼠标右键事件
document.onkeydown = ctrl_key; //绑定禁用键盘事件
function click() {
if (event.button == 2) //单击的鼠标键为右键
{
alert('请尊重本网站版权!');
return false;
}
}
function ctrl_key() {
if (event.keyCode == 17) { //禁用CTRL+S 保存网页代码
window.alert("请尊重本网站版权!");
return false;
}

if (event.keyCode == 123) { //禁用F12查看源代码
alert('请尊重本网站版权!');
return false;
}
}
</script>