Ched Jose Ched Jose - 1 year ago 159
HTML Question

Password protected download link

I want to make a simple password protected link that enables users (with the correct password) to download a zip file. The link, as in the code below, is "folder/". The link is a simple text ("Open"), not a button. I don't have any experience with javascript. The problem is that the password protection does not work when I tried. I just want to know how can I edit the code below to make it work?.. I don't have any experience with javascript so I appreciate any help!


<a href="folder/">open</a>


<SCRIPT type="text/javascript">
function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1)
if (pass1.toLowerCase() == "teacher") {
alert('You Got it Right!');'folder/');
var pass1 = prompt('Access Denied - Password Incorrect, Please Try Again.','Password');
if (pass1.toLowerCase()!="password" & testV ==3)
return " ";
<input type="text" value="Enter Protected Area" onClick="passWord()">

Answer Source

try the below code,


 function passwd(){

  var password = prompt('Enter the password to download the file:');
  if(password.toLowerCase() == "teacher"){"folder/")    
    alert("incorrect password!! please try again");


<input type="button" value="download zip file" onClick="passwd()"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download