首页 > Web开发 > 详细

js功能检测

时间:2017-08-23 18:52:57      阅读:243      评论:0      收藏:0      [点我收藏+]

怎么检测浏览器是否支持某一功能?

 1 function isLocalStorageSupported() {
 2     var testKey = ‘test‘,
 3         storage = window.sessionStorage;
 4     try {
 5         storage.setItem(testKey, ‘testValue‘);
 6         storage.removeItem(testKey);
 7         return true;
 8     } catch (error) {
 9         return false;
10     }
11 }

看到这段代码,挺不错的。

js功能检测

原文:http://www.cnblogs.com/newh5/p/7419510.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!