search

Home  >  Q&A  >  body text

html5 - 为什么Edge浏览器不支持localstorage?

连IE8及以上都能够支持,为什么Edge不能够支持?

if(window.localStorage){
 alert('This browser supports localStorage');
}else{
 alert('This browser does NOT support localStorage');
}


下面是Edge版本:

天蓬老师天蓬老师2787 days ago1090

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 13:12:03

    EDGE does not support localStorage in local files (this seems to be the case for IE10 and 11)
    You need to build a server and try again
    Or you can open F12 directly in the segmentfault webpage Try again and it will be supported

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:12:03

    It is supported, but your code cannot tell whether it is supported!
    You'd better check the context of your code, the introduction method, etc.

    Check whether it can output in the browser debugging console, F12-Console, enter localStorage below, and press Enter.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 13:12:03

    I copied your code and ran it in Edge, the results are as follows:

    It can be seen that it is supported. Is there something wrong with your step? Try printing window.localStorage in cosole

    reply
    0
  • Cancelreply