1
\$\begingroup\$

This is an odd case scenario, but I would like to display a message that tells if indexedDB is not supported or if it is removed due to being in private mode (yes ie10+/edge remove indexedDB in private mode, crazy uh?).

I think found a way without doing crazy UA sniffing or documentMode hacks that I think could work.

if(!window.indexedDB && (window.PointerEvent || window.MSPointerEvent))
  document.body.innerHTML = "Can't use indexedDB because you are in private mode"
else if(!window.indexedDB)
  document.body.innerHTML = "Can't use indexedDB because you don't have it"
else
  document.body.innerHTML = "woho"
  // Other browser in private mode can block indexedb
  // but the message gets handled from db.onerror instead

  • IE/Edge is the only browser that removes indexedDB when using inPrivate mode..?
    so this is a way to detect private mode, but then you have to figure out if it is ie10+ or edge.
  • so ie10 was the latest browser with support for indexedDB
  • and ie10+edge is the only browser that support pointerEvent [caniuse]

And I assume there is no other browser with support for pointerEvent and not having indexedDB at the same time that could yield wrong message.

What do you think about this? Good, bad? Any suggestions? It would help if you could test if this works in your browser (I don't have Windows).

\$\endgroup\$
2
\$\begingroup\$

Instead of blacklisting why not whitelist? If you are really just trying to post a message to the user saying your browser doesn't support something, why not just check if indexedDB is available and then if it isn't post something like:

"IndexedDB is only supported in Chrome 24.0, Firefox 16.0, IE 10/Edge, Opera 15 and Safari 7.1 or higher. It may also not work in certain 'Private' mode browsers. Please upgrade your browser to use the full power of our website."

This way you are avoiding lots of attempts of browser detection (which will more than likely break after browsers implement cross compatibility) and provides action for your user on what they can do next (try a different browser, upgrade, not be in private mode, etc).

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Not going to do that \$\endgroup\$ – Endless May 7 '16 at 8:48
  • \$\begingroup\$ No worries, just thought I would mention it because I wasn't seeing very many answers and white lists are easier to support than black lists (generally features don't get removed, only added) so maybe it could have been an alternative. Good luck! \$\endgroup\$ – k2snowman69 May 14 '16 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.