我正在尝试使 jquery 中的这个简单密码功能按我的需要工作。现在,在页面加载时,系统会提示您输入密码以查看页面正文。如果密码不正确,您会收到错误提示。这一切都有效,但它从那里死了。
我需要的是警报中的“重试”按钮,它只是刷新页面,以便您可以重试。我该怎么做呢?也许有人有一个可行的解决方案?
我无法在此类任务中正确使用 js fiddle,因为如果 pass 不正确,您将无法看到代码(因此看不到我的问题)。所以,我必须在这里粘贴所有代码。我希望没关系。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>-</title>
</head>
<body style="display:none;color: #000;">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/Javascript">
$( document ).ready(function() {
var password
var pass1="123"
password=prompt('Please enter password to view page')
if (password==123)
{ $('body').show(); }
else{
alert('password incorrect! Try Again!')
}
});
</script>
This is the page content that was password protected
</body>
</html>