Using the onload event to deal with cookies: - Javascript DOM Event

Javascript examples for DOM Event:onload

Description

Using the onload event to deal with cookies:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body onload="checkCookies()">

<p id="demo"></p>

<script>
function checkCookies() {//from   ww w  .  java  2 s. c  om
    var text = "";
    if (navigator.cookieEnabled == true) {
        text = "Cookies are enabled.";
    } else {
        text = "Cookies are not enabled.";
    }
    document.getElementById("demo").innerHTML = text;
}
</script>

</body>
</html>

Related Tutorials