/    Sign up×
Community /Pin to ProfileBookmark

Using JS to login with .htaccess

Hi all,

I’ve just implemented a script on my site to enable users to login via a small form rather than using the lame popup box that is usually used for .htaccess protected directories.

Does anyone know if there’s a reason this isn’t working in IE? It works ok in FF and I’m pretty sure there’s nothing wrong with the code cos it’s a popular snippet and pretty much the only one available on most script sites that can do this. I’m quite sure it’s one of the two lines in bold that isn’t working right:

[I](I just get an error in IE and the page does nothing, but in FF it jumps to the specified page.)[/I]

[CODE]<!– Begin
function login(form)
{
var username = form.username.value;
var password = form.password.value;
var server = form.server.value;
if (username && password && server)
{
[B]var htsite = “http://” + username + “:” + password + “@” + server;
window.location.href = htsite;[/B]
}
else
{
alert(“Please enter your username and password.”);
}
}
// End –>

<form name=form1>

<!– The hidden form field “server” needs to be the address of your password protected directory. –>

<input type=”hidden” name=”server” value=”www.utilitiessolutions.pwp.blueyonder.co.uk/agent/”>

<b>Username:</b>
<input type=text name=username size=20 style=”font-size: 12px”>

<b>Password:</b>
<input type=password name=password size=20 style=”font-size: 12px”>

<input type=button name=”button”value=”login” onClick=”login(this.form)” style=”font-size: 10px”>

</form>[/CODE]

I think it may be due to a security update at some point along the line – but any help is much appreciated, as I’m no expert coder myself. :rolleyes: and I’d rather get this sorted than have to resort to a server-side solution.

Thanks all, Drew

[URL=”http://www.utilitiessolutions.co.uk”]Utilities Solutions – Business Electricity, Gas & Telecoms[/URL]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@alpinenutFeb 27.2007 — Hi Drew,

Did you ever find a fix for this as I have the exact same problem. FireFox works great but IE7 not.

Cheers,

Adrian.
Copy linkTweet thisAlerts:
@SluggehauthorFeb 27.2007 — Hi Adrian,

Unfortunately I couldn't fix it. I'm guessing that it's just a security update or something they've changed that's stopping it work in the new IE7.

I reckon more and more people are resorting to server-side logins as they are much securer etc.

Time to learn PHP then!

Drew

Utilities Solutions - Business Electricity, Gas & Telecoms
×

Success!

Help @Sluggeh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.30,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...