We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

概述

返回一个布尔值,表明当前页面是否启用了cookies(只读属性)

语法

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

例子

if (!navigator.cookieEnabled) { 
  // 让用户知道,开启网页中的cookies是很有必要的.
}

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? 1.0 (1.7 or earlier) ? ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 1.0 (1) ? ? ?

Gecko备注

在Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5)之前的版本中, 当页面出现异常时,window.navigator.cookieEnabled 可能会返回错误的值. 目前该bug已经被修复.

规范

DOM Level 0 不属于任何标准.

文档标签和贡献者

此页面的贡献者: teoli, jsx, ziyunfei
最后编辑者: teoli,