PDA

View Full Version : simple password script fails in IE7 ?



pwallas
03-18-2007, 03:54 PM
With zero Javascript experience, I long ago found a simple password script to provide very minimal access control to some web pages I maintain. Now that I've upgraded to IE7, I find the script does not work, or I don't yet know how to set IE7 to allow it to work. What I've been using has the advantage of not including the password in the script, but the disadvantage that everyone (members of a local homeowners' association) has the same "password"

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var password = ''
password=prompt('Please enter your password:','');
if (password != null) {
location.href= password + ".html";
}
// End -->
</SCRIPT>

Right now, when the script runs, IE7's information bar says a scripted window is asking for information, but when I allow that window, box to enter the "password" does not appear. If anyone can help me fix the script or figure out how IE7 needs to be set, that would be great.
Thanks,
Phil Wallas

pcbrainbuster
03-18-2007, 04:34 PM
Well Phil I do not know exactly what you want but the below code will have a box requiring you to input the password test and if you do type in test in the box it will say in an alert COOL -

<html>
<body>
<input type="password" id="passbox"> <input type="button" onclick="passcheck()" value="Submit">
<script>
function passcheck() {
if (document.getElementById('passbox').value=="test") {alert("COOL")}
}
</script>
</body>
</html>

I have tested this in IE7 and it does work... If it does not work on your side you probably have disabled javascript or something...

Hope this helps :)