安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

credentials 特性为 Navigator interface returns the CredentialsContainer interface, which exposes methods to request credentials. The CredentialsContainer interface also notifies the user agent when an interesting event occurs, such as a successful sign-in or sign-out. This interface can be used for feature detection.

句法

var credentialsContainer = navigator.credentials
					

CredentialsContainer 接口。

范例

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

规范

规范 状态 注释
Credential Management Level 1 工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
credentials Chrome 51 Edge 18 Firefox Yes IE ? Opera Yes Safari ? WebView Android 51 Chrome Android 51 Firefox Android Yes Opera Android ? Safari iOS ? Samsung Internet Android 5.0

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

元数据

  • 最后修改: