Tag Archives: mobile

Update offline application cache

You can automate this. To update users to the newest version of your site, set a listener to monitor the updateready event on page load:

// storage interface, for more details storage implemments see https://gist.github.com/allex/a9b431ebcc921f2b309d
var storage = {
  get: function(k) {},
  set: function(k, v) {},
  remove: function(k) {}

window.onload = function(e) {
  var appCache = window.applicationCache;
  if (!appCache) { return; }

  // update offline.manifest caches if possible.
  appCache.addEventListener('updateready', function(e) {
    if (appCache.status === appCache.UPDATEREADY) {
      // Browser downloaded a new app cache.
      // Swap it in and reload the page to get the new hotness.
      try { appCache.swapCache(); } catch (e) {}
      if ( confirm('A new version of this site is available. Load it?') ) {
        storage.set('reload_flag', 1);
    else {
      // Manifest didn't changed. Nothing new to server.
  }, false);

  // The manifest returns 404 or 410, the download failed,
  // or the manifest changed while the download was in progress.
  appCache.addEventListener('error', function(e) {
    var reload_flag = parseInt(storage.get('reload_flag'), 10) || 0;
    if (navigator.onLine && reload_flag > 0) {
      storage.set('reload_flag', 0);
  }, false);

  function reload() {

Reference Links:

Mobile safari manually focus text field failed using a delay.

button.addEventListener('click', function() {
    // *** If triggered immediately - functionality occurs as expected
    // input.focus();
    // *** If called by callback - triggers the focusin event, but does not bring up keyboard or cursor
    setTimeout(function() {
    }, 10);

Remember that on iOS setting focus on an input element brings up the keyboard – so all those web pages out there that set focus on an input element on page load, like Google does, would be extremely annoying to use on iOS. I guess Apple decided they had to do something to prevent this. this is a feature not a bug.

There’s no known workaround for this, so you’ll have to ditch the idea of using a delay.