Thursday, February 2, 2017
Wednesday, February 1, 2017
Web Browser Sniffing
function get_browser_name($user_agent) { if (strpos($user_agent, 'opera') || strpos($user_agent, 'opr/')) return 'opera'; elseif (strpos($user_agent, 'edge')) return 'edge'; elseif (strpos($user_agent, 'chrome')) return 'chrome'; elseif (strpos($user_agent, 'safari')) return 'safari'; elseif (strpos($user_agent, 'firefox')) return 'firefox'; elseif (strpos($user_agent, 'msie') || strpos($user_agent, 'trident/7')) return 'internet explorer'; elseif (strpos($user_agent, 'ipad')) return 'ipad'; return 'Other'; } $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $browser = get_browser_name($userAgent); (javascript) var userAgent = ''; var browser = ''; console.log('userAgent '+userAgent); console.log('browser '+browser);
Subscribe to:
Posts (Atom)