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)



Single Articles
How to add a JavaScript immediately after a page has been loadedWindow Event Attributes
How to use onload on an <img> element. Alert "Image is loaded" immediately after an image has been loadedWindow Event Attributes
How to use the onload event to deal with cookies (using "advanced" javascript)Window Event Attributes


Related Articles
HTML onafterprint Event Attribute Window Event Attributes
HTML onbeforeprint Event Attribute Window Event Attributes
HTML onbeforeunload Event Attribute Window Event Attributes
HTML onerror Event Attribute Window Event Attributes
HTML onhashchange Event Attribute Window Event Attributes
HTML onload Event Attribute Window Event Attributes
HTML onoffline Event Attribute Window Event Attributes
HTML ononline Event Attribute Window Event Attributes
HTML onpageshow Event Attribute Window Event Attributes
HTML onresize Event Attribute Window Event Attributes
HTML onunload Event Attribute Window Event Attributes

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