Pergunta

the box appears in below snapshot is neither alert box,prompt box nor confirm box. then what is this? how can i create the same thing like this?

enter image description here

Foi útil?

Solução

It's a BasicAuth prompt, if your server return a request for BasicAuth it will get handled by the browser.

It happens when the browser receives a response with a header that looks like this, "insert realm" can be almost anything:

WWW-Authenticate: Basic realm="insert realm"

Usually the web browser handles it by itself and shows that kind of prompt. By the way it's unrelated to the web server as it's part of the protocole. If you happen to run an application server, you'll have to send the header above in a response and expect an Authorization header back from the "web client".

If you run apache, nginx, you can check simply for BasicAuth and you should be able to find documentation on how to set it up.

Read more here: BasicAuth

If you have enough courage you can read the RFCs

Outras dicas

This is a simple HTTP Authentification, like the one you can setup with a ".htpasswd" file on Apache and so on.

You can't do it with Javascript (it's on server-side), in PHP it would be like this

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top