Loading and Saving Dates
Virtually all modern browsers are implementing “local storage”, a service to store data locally on the device. The localStorage object implements a so-called key-value store. That works cross-platform amazingly well.
Surprisingly, the standard methods such as date.parse() are not very helpful. The only defined date format is RFC2822, but this format is optimized for English-language people. A date in this format will look like this:
“Mon, 31 Dec 1995 12:30:00”
A much better format is defined in ISO 8601. Dates will look like this: “YYYY-MM-DDThh:mmTZD“.
The complexity is much lower. No month names or week day names must be parsed, and the fields are in a fixed position. So it is much easier to read and write for computers.
Dialogs and the prompt-method
The dialogs of this methods are presented in the correct platform-specific design automatically. Since there are modal dialogs, the application logic becomes trivial. If we want to ask the user for a string, this simple program line is enough:
username = prompt(‘Your username’);
However, Microsoft decided that the prompt-method is a security problem. Because of this, prompt() is no longer supported in Internet Explorer starting with version 7 (in the default setting), and also not in Windows Mobile.
Annoying is that the Windows Mobile browser suppresses the dialog “secretly”. We can not distinguish the result of the suppressed prompt()-call from an empty user input, and so we can no longer react and offer alternatives for text input. So we need to do the unpopular “browser sniffing” again.