How do I check if my application is open on mobile or web?

4

I need to make a style.css for mobile and another for web.

    
asked by anonymous 28.08.2015 / 14:39

2 answers

-1
function isMobile() {
   return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER['HTTP_USER_AGENT']);
}

Personal has a script that detects where your application is being accessed follow the link below: link

    
18.09.2015 / 15:11
3

I do not know anything that completely separates desktop mobile, because you have many factors that can influence this, for example, there are still mobile that have no touch, there is the aspect ratio of the device where you can not simply say that 800px is mobile or not. it all depends on what you need to do!

If you just want to make a responsive layout you can delimit min or max width through the media query. I recommend these two readings: Tableless and MDN .

Now, if you want to check the touch issue you can use this code in javascript:

if(('ontouchstart' in window)){
    //seu cod. aqui!
}

If you can better define what you need, I can help you further.

    
28.08.2015 / 14:56