<legend id='ww06s'><style id='ww06s'><dir id='ww06s'><q id='ww06s'></q></dir></style></legend>

<small id='ww06s'></small><noframes id='ww06s'>

        <tfoot id='ww06s'></tfoot>
          <bdo id='ww06s'></bdo><ul id='ww06s'></ul>
        <i id='ww06s'><tr id='ww06s'><dt id='ww06s'><q id='ww06s'><span id='ww06s'><b id='ww06s'><form id='ww06s'><ins id='ww06s'></ins><ul id='ww06s'></ul><sub id='ww06s'></sub></form><legend id='ww06s'></legend><bdo id='ww06s'><pre id='ww06s'><center id='ww06s'></center></pre></bdo></b><th id='ww06s'></th></span></q></dt></tr></i><div id='ww06s'><tfoot id='ww06s'></tfoot><dl id='ww06s'><fieldset id='ww06s'></fieldset></dl></div>

        如何隐藏通过 JavaScript 对话框提示输入的密码?

        时间:2023-10-21
            <tbody id='R7IFP'></tbody>
          <tfoot id='R7IFP'></tfoot>

        1. <i id='R7IFP'><tr id='R7IFP'><dt id='R7IFP'><q id='R7IFP'><span id='R7IFP'><b id='R7IFP'><form id='R7IFP'><ins id='R7IFP'></ins><ul id='R7IFP'></ul><sub id='R7IFP'></sub></form><legend id='R7IFP'></legend><bdo id='R7IFP'><pre id='R7IFP'><center id='R7IFP'></center></pre></bdo></b><th id='R7IFP'></th></span></q></dt></tr></i><div id='R7IFP'><tfoot id='R7IFP'></tfoot><dl id='R7IFP'><fieldset id='R7IFP'></fieldset></dl></div>
          <legend id='R7IFP'><style id='R7IFP'><dir id='R7IFP'><q id='R7IFP'></q></dir></style></legend>

                <bdo id='R7IFP'></bdo><ul id='R7IFP'></ul>

              • <small id='R7IFP'></small><noframes id='R7IFP'>

                  本文介绍了如何隐藏通过 JavaScript 对话框提示输入的密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在 JavaScript 的对话框提示中隐藏用户输入的密码?例如,使用类似的东西

                  How can I hide the password entered by a user in a dialog prompt in JavaScript? For example, using something like

                  var passwd = prompt("Enter Password : ", "your password here");
                  

                  我希望在例如输入12345,在对话框中显示为*****......

                  I would like that when e.g. 12345 is entered, it appears like ***** or ..... in the dialog box.

                  谁能建议我如何做到这一点或提供一些示例代码?

                  Can anyone suggest how I can do this or provide some example code?

                  推荐答案

                  你在寻找 提示函数?

                  Are you looking for the prompt function?

                  var response = prompt("What is your name?");
                  
                  alert("Hello, " + response);
                  

                  对话框将如下所示:

                  这可能不是获取密码输入的最佳方式,因为它不会屏蔽输入.相反,请考虑使用带有密码输入字段的 HTML 表单.

                  This this probably isn't the best way to get password input, because it does not mask the input. Instead, consider using an HTML form with a password input field.

                  也许您正在寻找基本的 HTTP 身份验证?

                  Maybe you are looking for basic HTTP authentication instead?

                  您可以通过让您的网络服务器发送一些标头来进行设置;以 PHP 为例:

                  You can set this by getting your web server to send a few headers; for example with PHP:

                  <?php
                  if (!isset($_SERVER['PHP_AUTH_USER'])) {
                      header('WWW-Authenticate: Basic realm="My Realm"');
                      header('HTTP/1.0 401 Unauthorized');
                      echo 'Text to send if user hits Cancel button';
                      exit;
                  } else {
                      echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
                      echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
                  }
                  ?>
                  

                  这将导致客户端显示如下对话框:

                  This will cause the client to show a dialog like this:

                  这篇关于如何隐藏通过 JavaScript 对话框提示输入的密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:输入type=password,不要让浏览器记住密码 下一篇:用于检查 4 个不同字符组中的至少 3 个的正则表达式

                  相关文章

                  • <bdo id='JI9C6'></bdo><ul id='JI9C6'></ul>
                • <i id='JI9C6'><tr id='JI9C6'><dt id='JI9C6'><q id='JI9C6'><span id='JI9C6'><b id='JI9C6'><form id='JI9C6'><ins id='JI9C6'></ins><ul id='JI9C6'></ul><sub id='JI9C6'></sub></form><legend id='JI9C6'></legend><bdo id='JI9C6'><pre id='JI9C6'><center id='JI9C6'></center></pre></bdo></b><th id='JI9C6'></th></span></q></dt></tr></i><div id='JI9C6'><tfoot id='JI9C6'></tfoot><dl id='JI9C6'><fieldset id='JI9C6'></fieldset></dl></div>

                  <small id='JI9C6'></small><noframes id='JI9C6'>

                      <tfoot id='JI9C6'></tfoot>
                      <legend id='JI9C6'><style id='JI9C6'><dir id='JI9C6'><q id='JI9C6'></q></dir></style></legend>