• 0

[JavaScript & HTML] One for the gurus


Question

Let's say I have a website, and access to certain directories are controlled via .htaccess files. As is expected, when a user attempts to access a page or file in said directories, he is prompted with a dialog box requesting his username and password. He enters it, and has access to all folders to which he is a member (his username is valid according to the .htaccess file).

Using only HTML & JavaScript, is it possible to retrieve the user's username? A simple test would be like this:

<script type="text/javascript">
function getUsername() {
/* work your magic here */
}

var userName = getUsername();
alert('you are '+userName);
</script>

If this is possible, please help me out. Google searches and perusals through JavaScript references haven't turned up anything

Link to comment
https://www.neowin.net/forum/topic/393148-javascript-html-one-for-the-gurus/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I havent done any research, but my hunch tells me its NOT possible. Here's why:

1.) Logging in with .htaccess is a server side authentication method.

2.) HTML & Javascript are both executed on the client side.

3.) I have never every seen this done in the feild.

  • 0

here is a link on how to read a file on a server with javascript

http://www.rgagnon.com/jsdetails/js-0034.html

it may not be exactly what you want, but you may be able to modify it to your needs

as nickg78 said, it would be much easier with PHP :)

  • 0

oh, i know it'd be easy with any type of server-side language. the problem is i don't have the authority to put PHP or ASP access on the servers, and I can't be certain that those who do will allow it, so for right now I'm seeing if there are any possible client-side solutions.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.