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]
4 1254 gits 5,390
Recognized Expert Moderator Expert
hi ... -
-
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";
-
}
-
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
hi ... -
-
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";
-
}
-
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!!!
acoder 16,027
Recognized Expert Moderator MVP
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.
gits 5,390
Recognized Expert Moderator Expert
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Schraalhans Keukenmeester |
last post by:
I have no clue why below code (found it somewhere and altered it a wee
bit to my needs) will run without problem in both IE and Mozilla FireFox
1.0 but in the latter it takes up close to 100% cpu....
|
by: Todd Cary |
last post by:
I inherited an application where the Flyout works in Firefox but not in
IE. My JavaScript background is sparse, so I am not sure how to
approach the problem. Any suggestions are welcomed!
The...
|
by: expertware |
last post by:
Dear friends,
My name is Pamela, I know little about CSS,
but I would like to ask a question
I have an image on a web page within a css layer:
<DIV ID=MyLayer
STYLE = "position:...
|
by: Cuthbert |
last post by:
After compiling the source code with gcc v.4.1.1, I got a warning
message:
"/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the
'gets' function is dangerous and should not be...
|
by: Jim Carr |
last post by:
Upon entering the site www.FutureByDesign-Music.com with IE6, my clipboard
is erased and then disabled in all other Windows XP applications. Navigating
to another site returns clipboard...
| |
by: Xah Lee |
last post by:
Look at this page
http://xahlee.org/emacs/wrap-url.html
Look at it in Firebox, look at it in Safari, in Opera, and look at it
in Microsoft Internet Explorer.
The only fucked up case, is...
|
by: mavigozler |
last post by:
IE7 does not appear to set an event on contained text inside SPAN elements
whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML
recommendation. Firefox appears to conform.
...
|
by: loveshack |
last post by:
Can anyone help me please (i am quite a novice, but having fun learning). Im not sure if this is an ASP problem, a javascript problem or a browser problem.
Firstly, everything i have written...
|
by: zalek |
last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET",
url, false).
I noticed that in FireFox handler doesn't starts. It starts when I use
xmlHttp.open("GET", url,true).
I need to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |