本文介绍了检测浏览器中的 flex-wrap 支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在做一个项目,在该项目中我有一个使用 flex wrap 属性实现的响应式网格.由于我支持 IE9 和更低版本的 Firefox,版本 28 及更低版本,我如何通过 javascript 找出对相同版本的支持.目前我只能通过条件语句识别 IE9 浏览器,但现在有人如何通过 javascript 检测 Firefox 旧版本.

I am working on a project in which I have a responsive grid which I have achieved using flex wrap property. Since I am supporting IE9 and lower versions of Firefox, version 28 and below, how do I find out, through javascript, the support for the same. Currently I have only been able to identify IE9 browser through conditional statement but does anyone now how to detect for Firefox older versions through javascript.

推荐答案

我发现这是最简单的方法:

I found that this is the simplest method:

var d = document.documentElement.style
if (('flexWrap' in d) || ('WebkitFlexWrap' in d) || ('msFlexWrap' in d)){
  alert('ok');
}

我也试过 hasOwnProperty 但它在 IE 和 FF 中不起作用.那么,当您只有 3 行 js 时,为什么还要使用 40 KB 的 Modernizr 呢?

I tried hasOwnProperty too but it doesn't work in IE and FF.So why use 40 KB of modernizr when you can have just 3 lines of js ?

这篇关于检测浏览器中的 flex-wrap 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:42