Navigator.userAgentの値から判定する方法です。
デバイスがiPhoneであるかの判定は、各ライブラリでは以下のように実装されています。
device = {};
// The client user agent string.
// Lowercase, so we can use the more efficient indexOf(), instead of Regex
userAgent = window.navigator.userAgent.toLowerCase();
device.iphone = function () {
return !device.windows() && find('iphone');
};
device.windows = function () {
return find('windows');
};
// Simple UA string search
find = function (needle) {
return userAgent.indexOf(needle) !== -1;
};
device.js/device.js at master · matthewhudson/device.js · GitHub
// store navigator properties to use later
var userAgent = 'navigator' in window && 'userAgent' in navigator && navigator.userAgent.toLowerCase() || '';
// is current device iphone?
is.iphone = function() {
return /iphone/i.test(userAgent);
is.js/is.js at master · arasatasaygin/is.js · GitHub
(function(a,b)
{
if(/ … |ip(hone|od)| … /i.test(a.substr(0,4)))
…
})(navigator.userAgent||navigator.vendor||window.opera, … );