-3

i was just wondering how you can require an authentication for your website. such like this in the picture: https://kb.tanium.com/images/thumb/5/58/AuthenticationRequired.png/700px-AuthenticationRequired.png

Can you do this with javascipt? Thanks for help

Manne Moses
  • 65
  • 1
  • 4

1 Answers1

0

That's a basic HTTP response code 401 that is sent to the browser upon a request. You can do it on your webserver by securing a folder/page with .htaccess file or directive, or you can return a 401 http response in your code (java, php or whatever you use) for example in java:

response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

Normally handle of 401 responses is the job of the browser, this has nothing to do with javascript. However you can try to change the defaut behavior of the browser by using javascript, try to take a look at this page. I'd recommend not doing so but instead do a html form that you can freely customize and let it return a form with your identifiers.

Community
  • 1
  • 1
Christophe
  • 2,131
  • 2
  • 21
  • 35