javascript实现简单滴对html页面加密码访问
[ 2016/07/23, JavaScript , 7446阅, 0评 ]

javascript实现简单滴对html页面加密码访问

效果如上图,代码如下:

<script language = JavaScript>
function password() {
	var testV = 1;
	var pass1 = prompt('请输入密码:', '');
	while (testV < 3) {
		if (!pass1) history.go(-1);
		if (pass1 == "123456") {
			alert('密码正确!');
			break;
		}
		testV += -1;
		var pass1 = prompt('密码错误!请重新输入:');
	}
	if (pass1 != "password" & testV == 3) history.go(-1);
	return " ";
}
document.write(password());
</script>

有朋自远方来...评论一下呗O(∩_∩)O