Try using something similar to
var agent=navigator.userAgent.toLowerCase(); var is_iphone = ((agent.indexOf('iphone')!=-1); if (is_iphone) { conditional code goes here }
Refresh . You can also redirect the user using the .htaccess file. This htaccess rule will check if the user is using an iPhone, and if so, redirect it to the "iphone" subdomain
RewriteEngine on RewriteCond %{HTTP_USER_AGENT} iPhone RewriteRule .* http://iphone.mydomain.com/ [R]
If you do not know how to use .htaccess files here - this is a blog post that I wrote earlier about this.
To add additional devices, add code similar to JavaScript:
var agent=navigator.userAgent.toLowerCase(); var is_iphone = ((agent.indexOf('iphone')!=-1); var is_ipad = ((agent.indexOf('ipad')!=-1); if (is_iphone || ipad) { conditional code goes here }
.htaccess
RewriteEngine on RewriteCond %{HTTP_USER_AGENT} iPhone RewriteCond %{HTTP_USER_AGENT} iPad RewriteRule .* http://ios.mydomain.com/ [R]
source share