3

I have some Jquery scroller.

For desktop browsers I use this construction:

holder.bind('mousedown.rotate', function(e){ //some actions doc.bind('mousemove.dragrotate', function(e){ //some actions }); doc.bind('mouseup.dragrotate', function(){ //some actions doc.unbind('.dragrotate'); }); }); 

for mobile browsers it works in this way:

holder.bind('touchmove', function(jQueryEvent) { //some actions }); 

what is the best way to determine mobile borwsers? is there a way to use same function for all platforms?

thx

1

2 Answers 2

3

You can use navigator.userAgent to check what browser the user is using... the following code would be a good starting point.

if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/webOS/i)) { // Mobile browser specific code here } 

Detect Mobile Browsers has a JS file you can use if you want to get more specific.

Sign up to request clarification or add additional context in comments.

Comments

1
var is_touch_device = 'ontouchstart' in document.documentElement; 

Detecting touch screen devices with Javascript

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.