开发者

How do I check if the browser supports cookies, in javascript? [duplicate]

开发者 https://www.devze.com 2022-12-24 05:53 出处:网络
This question alread开发者_C百科y has answers here: How to show a message only if cookies are disabled in browser? [duplicate]
This question alread开发者_C百科y has answers here: How to show a message only if cookies are disabled in browser? [duplicate] (4 answers) Check if the client accepts cookie in javascript? (3 answers) Closed 5 years ago.

Especially for the iPhone


This works in IE, Chrome and Safari (which should be the same as iPhone):

if (navigator.cookieEnabled)
   alert("ON");
else
   alert("OFF");

EDIT: Since nvl decided to take my answer and not check into it I thought I should. Tested it on all the browsers I could find and seems to work just fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消