detect browser to choose CSS file


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function queBrowser() {
  2. $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
  3. if (strpos($user_agent, 'Opera') !== false) {$browser = 'opera';
  4. } elseif (strpos($user_agent, 'Chrome') !== false) {$browser = 'estilos';
  5. } elseif (strpos($user_agent, 'Firefox/2') !== false) {$browser = 'estilos';
  6. } elseif (strpos($user_agent, 'Firefox/3') !== false) {$browser = 'estilos';
  7. } elseif (strpos($user_agent, 'Firefox') !== false) {$browser = 'estilos';
  8. } elseif (strpos($user_agent, 'Shiretoko') !== false) {$browser = 'estilos';
  9. } elseif (strpos($user_agent, 'Safari') !== false) {$browser = 'estilos';
  10. } elseif (strpos($user_agent, 'MSIE 6') !== false) {$browser = 'estilos-ie6';
  11. } elseif (strpos($user_agent, 'MSIE 7') !== false) {$browser = 'estilos-ie7';
  12. } elseif (strpos($user_agent, 'MSIE 8') !== false) {$browser = 'estilos-ie8';
  13. } elseif (strpos($user_agent, 'MSIE') !== false) {$browser = 'estilos-ie';
  14. } else {$browser = 'Otro';
  15. }
  16. return $browser;
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.