Tuesday, August 29, 2017

Does your browser support localStorage?

If your browser supports HTML5 then your browser supports local storage. The image below is for Microsoft Edge 15.


You can also view this HTML file (TodaysDate.html) below on your local IIS.



<html>
<body>

<div id="result"></div>

<script>
// Check browser support
if (typeof(Storage) !== "undefined") {
    // Store
    localStorage.setItem("Today", Date());
    // Retrieve
    document.getElementById("result").innerHTML = localStorage.getItem("Today");
} else {
    document.getElementById("result").innerHTML = "No browser support for localStorage";
}
</script>

</body>
</html>

If localStorage is supported then you should see the following (for today).

This also worked on IE 11 as well as Mozilla Firefox.




No comments: