With the return of jobs, IPad2 's release seems to be getting hotter on the mobile side of the development topic. Here's a list of some of the biggest competitors in iOS-the Android (Android) system detection method.
JavaScript Judgment method
Searching for the Android word in the user agent string is the most time-saving method:
- if (Navigator.userAgent.match (/android/i)) {
- Do something!
- Redirect to Android-site?
- window.location = ' http://android.davidwalsh.name ';
- }
How to Judge PHP
Again, we can use the Strstr method in PHP to search for Android in the user agent:
- if (strstr ($_server[' http_user_agent '], ' Android ')) {
- Header (' Location:http://android.davidwalsh.name ');
- Exit ();
- }
In addition, you can use the. htaccess to judge
We can use. htaccess to judge and respond to Android devices!
- Rewritecond%{http_user_agent} ^.*android.*$
- Rewriterule ^ (. *) $ http://android.davidwalsh.name [r=301]
So you have all the three kinds of detection methods for Android devices.
Original link: http://article.yeeyan.org/view/56089/176760
"Edit Recommendation"
- Deep understanding of the closure characteristics of JavaScript
- JavaScript cross-domain summarization and solutions
- Developing mobile applications using JavaScript
- Discussion on the evolution of garbage collection algorithm in PHP 5
- 1-minute perfect installation of the latest Centos+nginx+php-fpm+mysql
"Responsible editor: Chen Yu new TEL: (010) 68476606"