[英]I am trying to combine this javascript code?
因此,我試圖用密碼保護在我的網站上顯示一些文本的按鈕。 這是我擁有的密碼保護腳本的代碼。
<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>
Is無法弄清楚如何獲得它,以便在正確輸入密碼后顯示密碼按鈕,您可以在其中顯示/隱藏一些文本。
這應該工作
<!DOCTYPE html>
<html>
<head>
<SCRIPT>
// Show Div if its hidden
function showdiv(){
// get the div
which = document.getElementById('adiv');
// show hide
if (!which)
return
else if (which.style.visibility=="hidden")
which.style.visibility="visible";
}
// Test User Credentials
function passWord(){
var testV = 1;
var pass1 = prompt('Enter The Code On Your Card Here.'); // no need to give a space here
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == "abc123") {
showdiv()
alert("Redirecting in 3 secs...")
window.setTimeout(redirect,3000); //wait for 3 secs then redirect to card1.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 " ";
}
function redirect(){
window.open('card1e.html');
}
</SCRIPT>
</head>
<body>
<div id="adiv" style="font:24px bold; visibility:hidden">Now you see me</div>
<CENTER>
<input type="button" value="Click to enter credentials toe see the text block" onClick="passWord()">
</CENTER>
</body>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.