0
所以,我正在尝试密码保护一个按钮,显示我的网站上的一些文字。 下面是密码保护脚本的代码。我想结合这个JavaScript代码?
<SCRIPT>
function passWord() {
var testV = 1;
var pass1 = prompt('Enter The Code On Your Card Here.',' ');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == "abc123") {
window.open('card1e.html');
break;
}
testV+=1;
var pass1 =
prompt('Access Denied - Password Incorrect, Please Try Again.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3)
history.go(-1);
return " ";
}
</SCRIPT>
<CENTER>
<FORM>
<input type="button" value="Have This Card? Click Here!" onClick="passWord()">
</FORM>
</CENTER>
我使用的显示/隐藏脚本是这样的:
<script>
<a href="javascript:hideshow(document.getElementById('adiv'))">Click here</a>
<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>
<div id="adiv" style="font:24px bold; display: block">Now you see me</div>
是无法弄清楚如何得到它,这样,当输入正确的密码,它显示的按钮,你可以显示/隐藏一些文字。
修改了代码: 1.使用'block'我用'visibility' 2.合并守则就照你需要 3.增加了你在做JS超时函数,因为我不确定你想在你的代码中做什么。这会让最终用户在重定向到'card1.html'之前3秒钟阅读文本,可能只是'card1.html'上的文本?你最好的评委 – nimish
非常感谢你!我一直试图弄清楚这几个小时,现在我终于能够做到了。谢谢! – ben101