N
Noel S Pamfree
Problem 1
=======
I need to create a page for a friend who operates a school website. She
needs to set up a page so that only the Governors can access it. I thought
I'd try to use JavaScript to prompt for a password. (I am only an amateur at
writing JavaScript).
It works fine in my tests when using Firefox but when I load the page in
Internet Explorer it causes an error. (I am using the newest version 7 - the
one that keeps crashing!). Somehow when you click on the button to ask for
access to the page it doesn't prompt you for the password and a message
about not trusting scripts appears (but you can't get to it to say yes).
My test page is at www.uk.f2s.com/testhtm.htm and the password is "test".
The Java script I inserted is:
<script>
//We will first ask the user if s/he would like to continue into this
restricted area
var p=confirm("This page is for Governors only and it password protected, do
you still wish to enter?")
if(p){
<!-- Set Password here -->
var ans="test"
<!-- Enter Password here -->
var pass=prompt("Please enter the password")
<!-- Responses to Password here -->
if(pass!==ans)
{
<!-- User clicks on 'Cancel' -->
alert("Sorry that's wrong - you will now be returned to our home page!")
window.location="http://www.st-louismiddle.suffolk.sch.uk"
<!-- User enters correct password -->
}else{window.location="http://www.uk.f2s.com"}
<!-- User enters incorrect password -->
}else{alert("You will be returned to our home page")
window.location="http://www.st-louismiddle.suffolk.sch.uk"}
</script>
Problem 2
=======
I want asterisks to appear when the password is entered and not have the
characters appear on the screen but I don't know how to do it in JavaScript.
If anyone knows of a webpage that will help I would be very grateful.
Any help appreciated.
Noel
=======
I need to create a page for a friend who operates a school website. She
needs to set up a page so that only the Governors can access it. I thought
I'd try to use JavaScript to prompt for a password. (I am only an amateur at
writing JavaScript).
It works fine in my tests when using Firefox but when I load the page in
Internet Explorer it causes an error. (I am using the newest version 7 - the
one that keeps crashing!). Somehow when you click on the button to ask for
access to the page it doesn't prompt you for the password and a message
about not trusting scripts appears (but you can't get to it to say yes).
My test page is at www.uk.f2s.com/testhtm.htm and the password is "test".
The Java script I inserted is:
<script>
//We will first ask the user if s/he would like to continue into this
restricted area
var p=confirm("This page is for Governors only and it password protected, do
you still wish to enter?")
if(p){
<!-- Set Password here -->
var ans="test"
<!-- Enter Password here -->
var pass=prompt("Please enter the password")
<!-- Responses to Password here -->
if(pass!==ans)
{
<!-- User clicks on 'Cancel' -->
alert("Sorry that's wrong - you will now be returned to our home page!")
window.location="http://www.st-louismiddle.suffolk.sch.uk"
<!-- User enters correct password -->
}else{window.location="http://www.uk.f2s.com"}
<!-- User enters incorrect password -->
}else{alert("You will be returned to our home page")
window.location="http://www.st-louismiddle.suffolk.sch.uk"}
</script>
Problem 2
=======
I want asterisks to appear when the password is entered and not have the
characters appear on the screen but I don't know how to do it in JavaScript.
If anyone knows of a webpage that will help I would be very grateful.
Any help appreciated.
Noel