Try using navigator.userAgent.