连IE8及以上都能够支持,为什么Edge不能够支持?
if(window.localStorage){
alert('This browser supports localStorage');
}else{
alert('This browser does NOT support localStorage');
}
下面是Edge版本:
天蓬老师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
天蓬老师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.
怪我咯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