• 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.
  • Posts

    • Article needs to be updated. X posted yesterday, after 2.5 hours that most service was back.
    • Can't say that I cared for his more recent views, but the man was an icon and will be missed.
    • I don't have a computer to play these, but kudos for them to release this stuff.
    • Even msnbc can be nice.   
    • Meta pulls political ads in the EU due to new regulations by Paul Hill Meta has announced that it will no longer allow political, electoral, or social issue ads on its platforms in the European Union starting in early October 2025. This is in direct response to the EU’s upcoming Transparency and Targeting of Political Advertising (TTPA) regulation. According to the social media giant, the TTPA introduces “unworkable requirements and legal uncertainties” that make it too hard to continue offering those ad services. The ban on these types of ads will be limited to the EU and it will continue to allow political ads on its service in other parts of the world. The company will also allow people and politicians in the EU to post and debate politics organically on its platforms, they just can’t pay to amplify it. Meta said that the TTPA places extensive restrictions on ad targeting and delivery, and will make ads less relevant to users. It also believes that the measures undermine personalized advertising which it believes is crucial for advertisers and users. The company has already introduced transparency tools for political ads back in 2018, such as requiring authorization and public disclosure in its Ad Library. Commenting on its action, Meta said: With this ban in place, it will restrict how political and social issue advertisers can reach audiences through paid promotions on Meta’s platform. It could also impact the ability of voters to get comprehensive information about the various campaigns. On this point, Meta thinks personalized ads are critical for informing voters about important social issues. It’ll be interesting to see what impact this has on political campaigns in the EU. Those politicians without deep pockets may like this move as it creates a more level playing field and prevents those with deep pockets from drowning out other candidates’ voices. On the flip side, it could see candidates use less transparent methods to get their views across to the public. Source: Meta | Image via Depositphotos.com
  • Recent Achievements

    • Dedicated
      Snake Doc earned a badge
      Dedicated
    • One Month Later
      Philsl earned a badge
      One Month Later
    • One Year In
      armandointerior640 earned a badge
      One Year In
    • One Month Later
      armandointerior640 earned a badge
      One Month Later
    • Week One Done
      Itbob513626 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      613
    2. 2
      ATLien_0
      236
    3. 3
      Xenon
      156
    4. 4
      +FloatingFatMan
      123
    5. 5
      Michael Scrip
      113
  • Tell a friend

    Love Neowin? Tell a friend!