Why does Internet Explorer 11 not detect indexedDB

吃可爱长大的小学妹 提交于 2019-12-11 09:43:38

问题


I am trying to implement a simple web-app using indexedDB, and use this snippet of code to detect browser compatibility:

if(!window.indexedDB) {
   alert("Your browser does not support indexedDB.");
}

When run in Chrome it does not open an alert box(as expected), but when run in IE, the alert box pops up. I figured this was just a crappy version of Internet Explorer, so I checked. It was 11. I went to http://caniuse.com to see what version is supported, and IE 11 is supported. What is going wrong? am I using the wrong code to detect indexedDB?


回答1:


IE11 does indeed support IndexedDB and the code you provided looks reasonable, so if the alert isn't appearing, then there must be some other factor. You didn't mention much in the way of your environment, so here are a few things to look at:

  • If this a public webpage loaded through HTTP or HTTPS, it's likely you're not loading the page in edge mode, as in you may be using a DOCTYPE that does not render in edge mode (formerly known as standards mode). If you're not sure what this means, please make sure the first line in your webpage is <!doctype HTML>. (The tip about using F12 tools to verify the document is a good one.)

  • If this webpage is running on your local network (including your local hard drive), it's possible the page is being loaded in compatibility view. You'd want to add an x-ua-compatible header where "content="ie=edge".

  • One other possibility might be that, due to local group policy settings and/or other environmental factors, IndexedDB might be disabled. That's hard to predict, but one way to respond might be to try to test the feature using code that claims to work in an entirely different environment, e.g. a PC attached to some other environment, e.g. your home network.

Not sure precisely what to suggest at this point, but (hopefully) there's something useful here.

Hope this helps...

-- Lance



来源:https://stackoverflow.com/questions/29703520/why-does-internet-explorer-11-not-detect-indexeddb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!