Safari SecurityError: Dom Exception 18 thrown by localStorage or cookies are blocked

Please note an unhandled SecurityError (DOM Exception 18): The operation is insecure is thrown when calling window.localStorage from Safari on iOS 7.1.2 with blocked cookies (Settings > Safari > Block Cookies > Always).

It is caused by disabling cookies also disables localStorage. With other two choices of block cookies setting (“From third parties and […]

Continue reading


JavaScript: Literal Initialiser [] vs Constructor new Array() for Creating Arrays

The [] method is an array literal/array shorthand to initialise the array. The syntax is simple: a comma-separated list of values in square brackets []

The new Array() method is to create an instance by calling the array constructor. The new Array() syntax has three different forms: If you call the constructor with TWO […]

Continue reading


JavaScript: Alternative method for HTML 5 Data Attribute in Old Browsers

The HTML5 datalist property is not available in older browsers (it can be polyfilled easily enough though). The standard getAttribute method can be used instead of course, and data-xxx attributes on HTML elements are accepted by all browsers, IE also has supported this method from IE4. Sample HTML

JavaScript

Continue reading