Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/01/2014, 20:48
Avatar de berkeleyPunk
berkeleyPunk
 
Fecha de Ingreso: febrero-2013
Ubicación: México :C
Mensajes: 565
Antigüedad: 11 años, 3 meses
Puntos: 22
Pregunta Problema con añadir regla CSS según el navegador, con Javascirpt

Buenas noches.

Entiendo que IE (trabajo con la versión 11) no trabaja con las fuentes TTF, sino con las EOT.

Así las cosas, si el navegador resulta ser IE, entonces quisiera añadir una regla CSS con la fuente .eot. Y si resulta ser cualquier otro explorador, entonces añadir una fuente ttf.

Llevo lo siguiente, pero no sirve:


Código Archivo externo:
Ver original
  1. <link type="text/css" rel="stylesheet" href="hojaCSS.css" id="hojaCSS" />


Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.     window.onload = function()
  3.     {
  4.         var hojaCSS         = document.getElementById("hojaCSS");
  5.         var infDelNavegador = window.navigator.userAgent;
  6.         var trident         = infDelNavegador.indexOf("Trident");
  7.         var version11       = infDelNavegador.indexOf("rv:11.");
  8.        
  9.         if( (trident != -1) && (version11 != -1) )
  10.         {
  11.             alert("Es IE");
  12.             hojaCSS.innerHTML('@font-face {font-family:"Harlow Solid Italic"; font-weight:normal;   font-size:14px; src:url(HARLOWS.eot);}');
  13.         }
  14.         else
  15.         {
  16.             alert("No es IE");
  17.             hojaCSS.innerHTML('@font-face {font-family:"Harlow Solid Italic"; font-weight:normal;   font-size:14px; src:url(HARLOWSI.TTF);}');
  18.         }
  19.     }
  20. </script>

Código HTML:
Ver original
  1. <p>Este texto debe aparecer con fuente Harlowsi</p>


Saludos cordiales



PD. Perdón, se me fue. A ver si alguien puede mover este post a javascript.