frederik-b
frederik-b

Reputation: 178

Workaround for file input label click (Firefox) - jQuery 1.9

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.

Upvotes: 2

Views: 679

Answers (2)

daveyfaherty
daveyfaherty

Reputation: 4613

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?

Upvotes: 3

gustavohenke
gustavohenke

Reputation: 41440

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

Upvotes: 0

Related Questions