PDA

View Full Version : Why wont this code work?



iAdam
28-12-2005, 05:06 PM
<SCRIPT language="JavaScript"><!--hidevar password;var pass1="password";password=prompt('Please enter the Password:');if (password==pass1)alert('Password correct please wait to be directed to the page.');else { window.location="<a href=
"index.htm">"; }//--></SCRIPT>


The enter password window doesn't pop up for some reason. and before you ask no thats not my real password

nets
28-12-2005, 09:52 PM
You have two parse errors.
Error #1:

prompt('Please enter the Password:');
If you don't want any default text to appear in your script you still need to keep the quotes (just don't put anything in them).
Use this instead:

prompt('Please enter the Password:','');
Error #2:

window.location="<a href="index.htm">";
You don't need to make it a link, as its not a link.
Use this instead:

window.location="index.htm";

Edit: Also you'll want to space out the lines of code, because some statements are mixed with others (e.g. hide and var are on the same line). That is also stopping the script from working.

I know this is slightly off topic, but that script isn't very secure.

Anderman
28-12-2005, 09:55 PM
You really dont want to use that script
It is so easy to get around,
Use .htacess

iAdam
28-12-2005, 10:00 PM
Still wont work is it because im using freewebs?

EDIT: someone do it for me please im tired night all.

nets
28-12-2005, 10:09 PM
Still wont work is it because im using freewebs?

EDIT: someone do it for me please im tired night all.
I did explain what was wrong with it, and how to fix it.
Oh well, I'll fix it..


<SCRIPT language="JavaScript">
<!--hide
var password; var pass1="password";

password=prompt('Please enter the Password:','');


if (password==pass1)
alert('Password correct please wait to be directed to the page.');

else {
window.location="index.htm";
}
//-->
</SCRIPT>
That might work, test it.

iAdam
29-12-2005, 07:47 AM
It works thanks alot i would rep but it wont do owt cuz people are mardy and bad repped me for reportin a signature.

Want to hide these adverts? Register an account for free!