navigator.cookieEnabled 返回一个布尔值,来表示当前页面是否启用了 cookie。本属性为只读属性。

语法

let cookieEnabled = navigator.cookieEnabled;
  • cookieEnabled 是个布尔值truefalse

示例

if (!navigator.cookieEnabled) { 
  // 浏览器不支持 cookie,或者用户禁用了 cookie。
}

标准

标准 状态 备注
HTML Living Standard
Navigator.cookieEnabled
Living Standard 初次定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
cookieEnabledChrome Full support 59Edge Full support 12Firefox Full support 1
Notes
Full support 1
Notes
Notes Prior to Firefox 8, navigator.cookieEnabled would report the wrong result if a site exception was in place for the page on which the check was performed. This has been fixed.
IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support 59Chrome Android Full support 59Firefox Android Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 8, navigator.cookieEnabled would report the wrong result if a site exception was in place for the page on which the check was performed. This has been fixed.
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
See implementation notes.
See implementation notes.

文档标签和贡献者

标签: 
此页面的贡献者: mdnwebdocs-bot, Roy-Tian, teoli, jsx, ziyunfei
最后编辑者: mdnwebdocs-bot,