Ver Mensaje Individual
  #5 (permalink)  
Antiguo 02/08/2010, 23:25
canino_latino
 
Fecha de Ingreso: enero-2010
Mensajes: 113
Antigüedad: 14 años, 3 meses
Puntos: 2
Respuesta: Diferenciar en CSS para firefox e IE 7 u 8

Hola bueno mira yo he creado un javascript que lo uso en una de mis webs:

Código Javascript:
Ver original
  1. function chrome() {
  2. var chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  3. if(chrome) {
  4. document.getElementById('estilo').href="css/principalChrome.css";
  5. }
  6. var IE7 = navigator.userAgent.toLowerCase().indexOf('msie 7.0') > -1;
  7. if(IE7) {
  8. document.getElementById('estilo').href="css/principalIE7.css";
  9. }
  10. var IE8 = navigator.userAgent.toLowerCase().indexOf('msie 8.0') > -1;
  11. if(IE8) {
  12. document.getElementById('estilo').href="css/principalIE8.css";
  13. }
  14. }

asi se ve en codigo completo:

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="es">
  3. <title>Tu titulo</title>
  4. <script type="text/javascript">
  5. function chrome() {
  6. var chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  7. if(chrome) {
  8. document.getElementById('estilo').href="css/principalChrome.css";
  9. }
  10. var IE7 = navigator.userAgent.toLowerCase().indexOf('msie 7.0') > -1;
  11. if(IE7) {
  12. document.getElementById('estilo').href="css/principalIE7.css";
  13. }
  14. var IE8 = navigator.userAgent.toLowerCase().indexOf('msie 8.0') > -1;
  15. if(IE8) {
  16. document.getElementById('estilo').href="css/principalIE8.css";
  17. }
  18. }
  19. <script type="text/javascript">chrome();</script>
  20. <link href="css/principal.css" rel="stylesheet" type="text/css" id="estilo"/>
  21. </head>
  22. </body>
  23. </html>

de esta manera no necesitas condicionales ya que no los hay para todos los navegadores.

NOTA: principal.css es el de firefox ya que no lo idetificamos.

espero te sirva chao.