2

First of all this is very similiar to: Workaround for file input label click (Firefox)

but the provided solution is not working in jQuery 1.9+

The $.browser variable dosn't exist anymore because now we have to do feature detection.

I would very much like to detect the feature that I need but there seems to be no such support in jQuery. Browser detection is gone, feature detection seems not able to detect what I need, is there a good solution out there? A Modernizr solution would be appreciated aswell and also plain-vanilla-js solution is accepted

Thanks for your help.

Community
  • 1
  • 1
frederik-b
  • 178
  • 1
  • 6
  • If you mean reversing the order, that is not a solution. – frederik-b Feb 19 '13 at 16:42
  • I meant using the label click -> input click trigger solution, but that would result in double file dialogs in other browsers. I can't think of a way to detect support for this, so i'd suggest just looking at the useragent and detecting the specific browser and version(s) that is having this issue. – Kevin B Feb 19 '13 at 16:43

2 Answers2

3
if ( window.mozIndexedDB !== undefined ) {
   //do firefox things
}

This will only return true in Firefox, afaik.

Example test:

if ( window.mozIndexedDB !== undefined ) {
   alert('You are using Firefox');
}

You can try looking at window.navigator.userAgent but I don't recommend it, a bunch of other browsers identify as Mozilla, see this question for some examples: Why Does “navigator.userAgent” in javaScript returns the String “Mozilla” when tried in a google chrome borwser?

Community
  • 1
  • 1
daveyfaherty
  • 4,585
  • 2
  • 27
  • 42
0

Not the best practice, but why don't you try the jQuery Migrate plugin? It brings back $.browser, aswell some other removed features.

gustavohenke
  • 40,997
  • 14
  • 121
  • 129