Hi thanks, for
detect device user mobile or not, that's what i
mean
Not sure how many questions you are asking
here. Best to keep one per post!
What
is it you really want to test, and why? You should be testing for
something more specific than "mobile device". What
you should be testing depends on why you are testing for it.
Since
you said you want to scroll to some particular element, I think
"mobile device" is a meaningless concept. I'd think
all you care about is if the element is visible or not. If not, you
would scroll to it.
For other
purposes, you might want to know if the device has a touchscreen,
a mouse, or both.
And for yet
other purposes, you might like to know how fast the
user's connection is, and in a few cases, you might
actually want to know if they have a mobile connection,
because of some details of the specific nature of mobile
connections. (high latency, perhaps some timeout limits).
The days of
looking at screen dimensions and then deciding mobile/non-mobile
and using that yes/no for many purposes are long past. You
can't use screen dimensions to make that determination any
more, anyway. There are too many mobile devices, with too many
sizes, many of them with more pixels than desktop screens.
The one reason I
can think of for actually determining mobile/non-mobile (rather
than testing for specific characteristics of the device) would be
if you want to show material that would be particularly relevant
to a mobile user. Naive example: show a map if the user is mobile.
In that case,
though, you would more than likely show it to mobile and not show
it to desktop. since you asked about scrolling, I assume it is
because something you want the user to see might be off the screen
on a small device. Thus, the need is not for detecting mobile, but
simply insuring that what you want the user to see is seen. (So
scroll to it - the mysterious, important Content X.)
Is that what you want? Or something else?