Navigator: thuộc tính credentials

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2019.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Thuộc tính chỉ đọc credentials của giao diện Navigator trả về đối tượng CredentialsContainer được liên kết với tài liệu hiện tại, hiển thị các phương thức yêu cầu thông tin xác thực. Giao diện CredentialsContainer cũng thông báo cho tác nhân người dùng khi một sự kiện thú vị xảy ra, chẳng hạn như đăng nhập hoặc đăng xuất thành công. Giao diện này có thể được sử dụng để phát hiện tính năng.

Giá trị

Đối tượng CredentialsContainer.

Ví dụ

js
if ("credentials" in navigator) {
  navigator.credentials.get({ password: true }).then((creds) => {
    // Do something with the credentials.
  });
} else {
  // Handle sign-in the way you did before.
}

Thông số kỹ thuật

Specification
Credential Management Level 1
# framework-credential-management

Khả năng tương thích của trình duyệt