Horje

How to use the onload event to deal with cookies (using "advanced" javascript)

Here is Cookies are enabled.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body onload="checkCookies()">

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

<script>
function checkCookies() {
  let text = "";
  if (navigator.cookieEnabled == true) {
    text = "Cookies are enabled.";
  } else {
    text = "Cookies are not enabled.";
  }
  document.getElementById("demo").innerHTML = text;
}
</script>

</body>
</html> 

Output should be:

How to use the onload event to deal with cookies (using "advanced" javascript)




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Window Event Attributes
Uploaded by:
Admin