4

How can I check if the browser supports the Zoom css atribute? I know from Caniuse.com that only Firefoz does not support it, so, from this question (In Javascript, how do I determine if my current browser is Firefox on a computer vs everything else?) I tried:

if ($.browser.mozilla) { ... 

which returns me an error in chrome:

Cannot read property 'mozilla' of undefined

Another solution according to the answer is detectinf if the browser supports that function, how could I do that?

Community
  • 1
  • 1
sigmaxf
  • 7,998
  • 15
  • 65
  • 125
  • jQuery's `$.browser` has been deprecated and removed, as browser detection is generally a bad idea. You want feature detection instead. – adeneo May 18 '16 at 22:23
  • The real question is, why not just use [scale](http://caniuse.com/#feat=transforms2d) instead – adeneo May 18 '16 at 22:26
  • Scale has it's own problems, like blurring, zoom works better for Chrome and IE but I'll make firefox use scale – sigmaxf May 18 '16 at 22:31

2 Answers2

7

Here is how you could detect support for a CSS feature in plain JavaScript. (Replace zoom with whatever feature is needed.)

document.createElement("detect").style.zoom === ""
Tim Grant
  • 3,300
  • 4
  • 23
  • 31
2

I think this answer should help you : jquery determine if css zoom is available in browser

The best way is to use a JS library dedicated to test browser CSS capabilities like Modernizr does.

Community
  • 1
  • 1
Gagoo
  • 39
  • 4