HTML and CSS Reference
In-Depth Information
alert("Stored: "+olddate);
}
catch(e) {
alert("Error with use of local storage: "+e);}
}
If you removed the if (typeof(localStorage) test and tried the code in the old IE, youd see the
message shown in Figure 7-15.
Figure 7-15. Browser error, caught in a try/catch
The Table 7-1 shows the complete date application. Remember: you may need to upload this to a server to
test it.
Table 7-1. Complete Code for the Date Application
Code
Explanation
<html>
Opening html tag
<head>
Opening head tag
<title>Local Storage test</title>
Complete title
<script>
Opening script
function store() {
Store function header
if (typeof(localStorage) == "undefined") {
Check if localStorage recognized
alert("Browser does not recognize HTML local
storage.");
Display alert message
Close if clause
}
else {
Else
Search WWH ::




Custom Search