This article describes the method of JavaScript to detect whether a browser cookie has been started. Share it for your reference. The specific analysis is as follows:
JavaScript detects whether the browser cookie has started. The code is a bit complicated. By writing a test cookie, it determines whether the cookie has started.
var dt = new Date(); dt.setSeconds(dt.getSeconds() + 60); document.cookie = "cookietest=1; expires=" + dt.toGMTString(); var cookiesEnabled = document.cookie.indexOf("cookietest=") != -1; if(!cookiesEnabled) { alert('No cookie enabled');}I hope this article will be helpful to everyone's JavaScript programming.