View Single Post
Old 05-09-2008, 06:37 AM   #1 (permalink)
Aaron777
Registered User
 
Aaron777's Avatar
 
Join Date: Mar 2008
Posts: 4
OS: Windows XP sp2

My System

[SOLVED] javascript password script with IE7 prompt?

Hello all, I am a javascript newb, and I want to put simple password protection on a webpage. I found a simple script that gets the job done (goes in the head section of my webpage), except it doesnt work in IE7, because prompts no longer work in IE7:
-----
<script>
var p=confirm("This page is password protected, do you still want to enter?")
if(p){
var ans="asdfasdf"
var pass=prompt("Please enter the password.")
if(pass!==ans)
{
alert("Wrong password, please try again.")
window.location="www.google.com"
}else{alert("Welcome!");}
}else{window.location="www.google.com"}
</script>
-----
This works in everything but IE7
I found a solution to the prompt problem in IE7, which creates a prompt, see this page:
http://www.hunlock.com/blogs/Working...ug,_er_feature
heres an example of how it works:
----
<script type='text/javascript' src='IEprompt.js'></script>
<script type='text/javascript'>
function promptCallback(val) {
alert(val);
}

IEprompt('Enter some text','default value');
</script>
-----

Can anyone show me how to incorporate the IEprompt into the password script? i have no idea how to do it?
Thanks in advance.
Aaron777 is offline   Reply With Quote