• 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.
  • Popular Now

  • Posts

    • I know Windows DHCP and DNS servers get teased a lot, but those services were at least created at a time when MS cared more than they do now, and they work mostly as expected. I actually use both in a multisite professional setting, not really because I love them, but because we use Active Directory and those services go hand-in-hand with it. A few times when I have needed to configure some more advanced features, I was worried Windows might not support them, but so far it has not let me down. I can only image the horror a Windows 11 era DHCP server would be, probably fewer options than the basic service on a Netgear router.
    • Since the article doesn't cover it: >Pinned Tabs allow you to always keep your favorite tabs open and just a click away. Pinned Tabs are small, can't be closed accidentally, and open automatically when you start Firefox. from https://support.mozilla.org/en...keep-favorite-websites-open
    • CapCut 6.4.0 (offline installer) by Razvan Serea CapCut is a versatile video editing app that offers a range of features such as multi-layer editing, keyframe animations, special effects, and more, to create professional-quality videos. With CapCut, users can edit and enhance their videos with a variety of tools such as filters, transitions, effects, and text overlays. CapCut's extensive library of pre-designed templates and visual effects also allows users to create unique and eye-catching videos in just a few clicks. Users can also adjust video speed, crop, and merge multiple clips, among other features. CapCut is available for both mobile devices and Windows, making it accessible for everyone. CapCut key features: User-friendly interface for easy video editing A wide range of editing tools, including trim, split, cut, and merge Music library with a wide range of tracks to choose from Customizable text and fonts to add captions and titles Multi-layer timeline for seamless editing and layering Filters and effects to enhance video quality and style A variety of transitions to choose from Multiple aspect ratio options for different platforms Green screen/chroma key for adding custom backgrounds Overlays and stickers to add to your videos Easy exporting to different video formats and resolutions Large library of pre-designed templates and visual effects Customizable video thumbnails for branding Keyframe animation to add movement to your video Speed adjustment for slow motion or time-lapse effects Customizable transitions between clips Reverse video playback for creative effects Voiceover recording and editing for narrating your video Color grading tools and much more... Download: CapCut 6.4.0 | 709.0 MB (Freeware) Links: CapCut Website | CapCut Screenshot | CapCut Online Editor Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I love how everything is gold except the Trump name, which is usually gold. It's in red, but the US flag? No blue or red allowed. This is such a hack Photoshop job, I would have thought Jony Ive was behind it. But even he wouldn't show art this unfinished. Just this stupid.
    • >Unlimited talk time, messages, and internet As Captain Picard once said to the android nearby, "Data?"
  • Recent Achievements

    • Week One Done
      patrickft456 earned a badge
      Week One Done
    • One Month Later
      patrickft456 earned a badge
      One Month Later
    • One Month Later
      Jdoe25 earned a badge
      One Month Later
    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      640
    2. 2
      ATLien_0
      279
    3. 3
      +FloatingFatMan
      170
    4. 4
      Michael Scrip
      156
    5. 5
      Steven P.
      131
  • Tell a friend

    Love Neowin? Tell a friend!