【发布时间】:2013-02-24 04:45:57
【问题描述】:
所以我为我托管的寻宝游戏创建了一个网站,但我需要一个密码提示来显示几乎每个页面,以确保他们已经完成了继续前进的挑战。我正在使用 Jquery,让密码提示出现的唯一方法是在我刷新页面之后,这不好。我需要一种将一个页面链接到另一个页面的方法,并在他们看到该页面之前显示密码提示。这是重要的html。另外,如果可以的话。每当我刷新页面时,所有的 CSS 似乎都消失了,我留下了文字。如果你能请帮忙。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery</title>
<link rel="stylesheet" href="../themes/scavenger-hunt.min.css" />
<link rel="stylesheet" href="../Publish/jquery-mobile/jquery.mobile.structure-1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.js"></script>
<body>
<script language="javascript">
var password
var pass1="123"
password=prompt('Please enter password to view page')
if (password==pass1)
alert('password correct! Press ok to continue.')
else{
window.location="index.html";
alert('password incorrect! Redirecting')
}
</script>
<div data-role="page" id="home">
<div data-role="header">
<h1>Hint 1</h1>
</div>
【问题讨论】:
-
这需要有多安全?因为如果我在你的寻宝游戏中,我会在十秒内绕过你的密码验证并获胜。
-
我没有看到 jquery 代码。
-
@mrtsherman 它不必那么安全,加上它的移动设备,所以它有点难以绕过。
-
@Dave Jquery 如下。我只是说它的 jquery,因为这可能是问题的一部分。如果你愿意,我可以显示整个页面
标签: javascript jquery html password-protection