0

javascript var stop?

Is there a way if you don't answer "1234" is there a way that the page won't load. var b = ("*****"); var password = prompt(" Enter password please!" , b); if (password==12345) { confirm("Access granted, Welcome") } else { alert("Get out of here") }

10th Jan 2017, 12:09 AM
Matrix Gaming
Matrix Gaming - avatar
5 Answers
+ 1
its better to loop until the password is correct, and then redirect to another site if there are too much tries. to change location: window.location.replace("http://google.com"); if not, you can use DOM and empty all the page.
10th Jan 2017, 12:48 AM
Nahuel
Nahuel - avatar
+ 1
while pass!= 1234 && tries<4 //code and tries++ else redirect
10th Jan 2017, 12:56 AM
Nahuel
Nahuel - avatar
0
how could i loop it?
10th Jan 2017, 12:53 AM
Matrix Gaming
Matrix Gaming - avatar
0
It's not working
10th Jan 2017, 1:46 AM
Matrix Gaming
Matrix Gaming - avatar
0
its not the literal code. You also have to create and assign var tries
10th Jan 2017, 2:19 AM
Nahuel
Nahuel - avatar