Detect if browser changed to selector?

Some browsers, especially mobile phone browsers, replace select boxes with their own spinner components. Is there a way to tell if the browser is using a spinner or a traditional selection?

+3


source to share


1 answer


Short answer

You don't have to be able to.

Longer answer

When you submit some HTML content, say:

<h1>Person Dies of Ebola</h1>

      

You don't have to think of it in terms of "well, this is a tag <h1>

, so the browser will make it bold and big." This does not mean what semantics means.

<h1>

is your way of telling the client browser "hey, this is heading level 1".



The browser can choose in a certain way for the user, but this is really not something you should rely on when writing your HTML.

When you have an item <select>

, you tell the client that you are going to describe a list of options in which the user must select one of them.

This will happen for popular browsers to implement interoperability functionality for you, but that doesn't mean you are writing something in <select>

. It's just the browser's way of trying to present your content to the client appropriately.

So, if you want to have a specific interaction that you want to implement, use JavaScript. Keep your HTML as it is, but write JavaScript that manipulates the DOM and implements the interaction you want.

But in kind ...

You can probably use user-agent

to determine which browser you are running in and what to do.

Here's a browser detection library that does some of these for you.

+1


source







All Articles