By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

why does firefox beat IE here?

P: 2
The following is the header of an html page that I want to password protect. In firefox everything works fine, but in IE, it automatically goes to the 'incorrect login' page without even prompting...... please help!!!!


[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Computer Science Reading Group: Restricted</title>
<SCRIPT language="JavaScript">
<!--
var username;
var password;
var user1="cs";
var pass1="42";
username=prompt('Please enter the username for CS Reading Group',' ');
password=prompt('Please enter the password for CS Reading Group',' ');
if ((username==user1) && (password==pass1))
alert('Welcome to the CS Reading Group! Click OK to Enter!');
else { window.location="incorrect.htm"; } //-->
</SCRIPT>
<style type="text/css">
.style1 {
text-align: center;
font-size: xx-large;
}
.style2 {
border-width: 0px;
}
.style3 {
text-align: left;
}
.style4 {
text-decoration: underline;
}
.style5 {
text-align: center;
font-size: large;
}
.style6 {
font-family: Calibri;
text-align: center;
}
.style7 {
text-align: center;
}
</style>
</head>[/HTML]
Oct 17 '07 #1
Share this Question
Share on Google+
4 Replies


gits
Expert Mod 5K+
P: 5,390
hi ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. var username;
  3. var password;
  4.  
  5. var user1="cs";
  6. var pass1="42";
  7.  
  8. username = prompt('Please enter the username for CS Reading Group',' ');
  9. password = prompt('Please enter the password for CS Reading Group',' ');
  10.  
  11. if ((username==user1) && (password==pass1)) {
  12.     alert('Welcome to the CS Reading Group! Click OK to Enter!');
  13. } else {
  14.     window.location="incorrect.htm";
  15. }
  16.  
that should work (which IE-version do you use?) ... but be aware ... everybody can read or change or hack that check on client-side (you may have a look at the source code anytime, and change the page locally) ... you should really do a serverside check ... never, never do this on client-side ...

kind regards
Oct 17 '07 #2

P: 2
hi ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. var username;
  3. var password;
  4.  
  5. var user1="cs";
  6. var pass1="42";
  7.  
  8. username = prompt('Please enter the username for CS Reading Group',' ');
  9. password = prompt('Please enter the password for CS Reading Group',' ');
  10.  
  11. if ((username==user1) && (password==pass1)) {
  12.     alert('Welcome to the CS Reading Group! Click OK to Enter!');
  13. } else {
  14.     window.location="incorrect.htm";
  15. }
  16.  
that should work (which IE-version do you use?) ... but be aware ... everybody can read or change or hack that check on client-side (you may have a look at the source code anytime, and change the page locally) ... you should really do a serverside check ... never, never do this on client-side ...

kind regards



I know about the 'insecurity' of javascript for password protection but I was just trying it temporarily......

But the problem still remains.....the code doesn't work with IE 6 or 7......plz help!!!
Oct 17 '07 #3

acoder
Expert Mod 15k+
P: 16,027
I'm not sure why your code doesn't work in IE6, but in IE7, the developers/designers decided that prompt was dangerous and it no longer works.

It has been badly implemented because if someone does allow the script to run, IE has already blocked it! Then if you refresh the page, it's conveniently forgotten that you've given permission for the script to run. Well done(!)

The solution is to write your own prompt script. If you search for "ie prompt alternative" or similar, you may get a pseudo-solution.
Oct 17 '07 #4

gits
Expert Mod 5K+
P: 5,390
hmmm ... the following example works with my IE6

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script typ="text/javascript">
<!--
function open_win(form) {

}
var username;
var password;

var user1="cs";
var pass1="42";

username = prompt('Please enter the username for CS Reading Group',' ');
password = prompt('Please enter the password for CS Reading Group',' ');

if ((username==user1) && (password==pass1)) {
alert('Welcome to the CS Reading Group! Click OK to Enter!');
} else {
window.location="incorrect.htm";
}
//-->
</script>
</head>
<body>
test
</body>
</html>
[/HTML]
do you get an error?

kind regards
Oct 17 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.