Detection Browser Supports Local Storage
Detection Browser Supports Local Storage
by Adi Jaya
HTML
<h2 id="demo"></h2>
CSS
#demo {
font-family : sans-serif;
color:white;
padding : 10px;
}
.red {
background-color:red;
}
.green {
background-color:green;
}
JavaScript
var selector = document.getElementById("demo");
// localStorage detection
function supportsLocalStorage() {
return typeof(Storage)!== 'undefined';
}
if (!supportsLocalStorage()) {
//No Support
selector.className = "red";
selector.innerHTML= "Your browser not Support HTML5 localStorage";
} else {
//Support
selector.className = "green";
selector.innerHTML= "Your browser Support HTML5 localStorage";
}