Detecting if the browser supports auto expanding the dropdown list?

In IE 6/7/8, a <select>

element, if given a specific width, is not automatically expanded upon opening. By using browser sniffing (the jQuery example had to use $.browser.msie

and $.browser.version

), I could identify the current browser with some degree of certainty and have the respective browsers add to the custom handler for selection.

In jQuery 1.9, the object $.browser

has been removed. I am still using the older version in production and I am able to browse sniff and show auto-expanding selection menus accordingly; However, this is not a long-term solution if we keep up with later versions of jQuery.

I've looked through the properties of the select through for(var i in document.createElement('select')) { ... }

, but I don't see anything obvious as to whether the menu will automatically open.

Is there such a thing? Ideally, I'm looking for a vanilla solution that doesn't require browser sniffing. if(!property in document.createElement('select')) { ... }

will be fantastic.

[Edit / Addition] I know jQuery is migrating and realizes that this is likely to call us. I'm not too keen to upload more stuff for one (for now) tiny inconvenience.

+3


source to share


1 answer


From the jQuery API jQuery.browser :

We do not recommend using this property; try using a function (see jQuery.support). jQuery.browser may be moved to a plugin in a future version of jQuery.



I researched and found the jQuery Migrate Plugin which has a $ .browser function, the code is available on github .

0


source







All Articles