3

As you might already know, the latest versions of jQuery remove $.browser support. I need to know if a user is using Firefox 3.6 or less. Is there any way to detect that using available features rather than looking at the user agent?

The reason we need this detection is that we style our upload buttons using another element, which then triggers a click on the invisible upload element. This does not work on FF <= 3.6.

Clarification

  1. Triggering an event on the upload like $('#uploader').trigger('click') is what does not work
  2. I do NOT want to look at the user agent to know this is the case, although saying that's the only way may be an acceptable answer
  3. I have no idea what this "feature" would be to detect it
Dave Stein
  • 8,653
  • 13
  • 56
  • 104
  • 2
    [The guide to detecting everything (HTML5)](http://diveinto.html5doctor.com/everything.html) – MDEV Aug 06 '13 at 14:15
  • What exactly about it doesn't work in FF <= 3.6? you might be able to feature detect it. – Kevin B Aug 06 '13 at 14:15
  • Is it the ability to click an invisible element that you're detecting? And in what way is it invisible - `visibility:hidden;` or `display:none;` or `opacity:0;` or `overflow:hidden;` ... etc – MDEV Aug 06 '13 at 14:16
  • 1
    It is the ability to trigger an upload by triggering a click event on the element. – Dave Stein Aug 06 '13 at 14:17
  • 1
    are you sure firefox 3.6 is the only browser that has that problem? i'm pretty sure it isn't. – Kevin B Aug 06 '13 at 14:20
  • @kevinB IE does as well, but there was an easy way to feature detect that through qquploader, but nothing for FF – Dave Stein Aug 06 '13 at 14:21
  • 1
    @DaveStein you maybe should then ask How to detect "the ability to trigger an upload by triggering a click event on the element" rather than the specific browser. – Zach Lysobey Aug 06 '13 at 14:21
  • Right, but it would probably be easier to just blanket fix it for all by positioning the fileinput above the button and making it invisible (but not hidden) – Kevin B Aug 06 '13 at 14:21

2 Answers2

3

Yes, in fact feature detection is the recommended way to do it rather than user agent detection. (hence why jQuery dropped the $.browser feature)

There are plenty of features that FF3.6 doesn't have, but your main aim should be to detect the ones that you specifically need to use.

Don't try to find out if the browser is FF3.6 based on the features; that is just defeating the whole point of feature detection. If you're doing that, you may as well do UA detection anyway.

What you need to do is just work out what features your site is using (you haven't mentioned anything about your site, so I can only guess here). Then do a detection script for any features you're using that would break your site if they weren't there, and have the site act accordingly when it finds a missing feature. (that could be warning the user that the site won't work, putting in an alternative, or loading a polyfill... exactly what you do would depend on what the feature is and what your site does with it)

PS - You might want to look into the Modernizr library for more help with feature detection.

Hope that helps.

[EDIT]

You mentioned the file upload feature... perhaps the answers here might help?

Community
  • 1
  • 1
Spudley
  • 166,037
  • 39
  • 233
  • 307
0

Browser detection is not a recommended technique- Take a look at this: Browser detection versus feature detection

Community
  • 1
  • 1
Steve H.
  • 6,912
  • 2
  • 30
  • 49
  • That's why I was asking if there was a feature that would not have been supported in 3.6 but is in 4... to detect it without looking at the browser specifically – Dave Stein Aug 06 '13 at 14:16