在 Firefox 手机上输入类型=“密码”发送点

问题描述 投票:0回答:1

在表单中使用时,在 Firefox 移动设备上发送到服务器的密码仅包含输入字段中显示的••• 点,而在其他浏览器上则发送输入的密码。

使用此 html 代码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
</head>

<body>
    <form action="/test">
        <input id="password" type="password" name="password" placeholder="Password" autocomplete="current-password">
        <button type="submit">Submit</button>
    </form>
</body>

</html>

当我使用

python -m http.server
提供此服务并在任何桌面浏览器或 Android 上的 Chrome 上输入 asdf 时,我会得到
?password=asdf
查询,而在 Firefox Mobile 123.0 (Android) 上我会得到
?password=%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2
,即编码的••••。我怎样才能让它像其他浏览器一样发送密码?

android html forms firefox
1个回答
0
投票

发生这种情况是因为 Firefox 对密码有额外的安全层,因为您实现它的方式并不安全。

如果您仍然想使用这种方式,可以使用 js 来解决。

这是js代码:

// Assuming you have an input field with the id "passwordField"
const passwordInput = document.getElementById("passwordField");

// Change the input type to "text" just before form submission
function revealPassword() {
    passwordInput.type = "text";
}

// Add an event listener to the form submission
const form = document.getElementById("yourFormId"); // Replace with your actual form ID
form.addEventListener("submit", revealPassword);

我希望这对您有所帮助,并且不要忘记更改

id
。 祝你有美好的一天:)

© www.soinside.com 2019 - 2024. All rights reserved.