Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

267
Vistas
El uso de `window.location.hash.includes` arroja "El objeto no es compatible con la propiedad o el método 'incluye'" en IE11

Estoy revisando la URL para ver si contiene o incluye un ? en él para controlar el estado pop hash en la ventana. Todos los demás navegadores no tienen problemas, solo IE.

El depurador me da este error cuando trato de cargar de esta manera:

El objeto no admite la propiedad o el método ' includes '

No recibo ningún error cuando cargo la página a través de popstate.

 $(document).ready(function(e) { if(window.location.hash) { var hash; if(window.location.hash.includes("?")) { alert('I have a ?'); hash = window.location.hash.substring(window.location.hash.indexOf('#') + 0,window.location.hash.indexOf('?')); }else { hash = window.location.hash; }; if (hash=="#DRS" || hash=="#DRP" || hash=="#DFFI" || hash=="#DCI" || hash=="#DCP" || hash=="#DRP" || hash=="#DRMA" || hash=="#EICS" || hash=="#ORG"){ $(hash+'Content').addClass('pageOn').removeClass('pageOff'); }else { $('#homeContent').addClass('pageOn').removeClass('pageOff'); }; } else { $('#homeContent').addClass('pageOn').removeClass('pageOff'); } $(window).on('popstate', function() { var hash; if(window.location.hash.includes("?")) { hash = window.location.hash.substring(window.location.hash.indexOf('#') + 0,window.location.hash.indexOf('?')); }else { hash = window.location.hash; }; if (hash=="#DRS" || hash=="#DRP" || hash=="#DFFI" || hash=="#DCI" || hash=="#DCP" || hash=="#DRP" || hash=="#DRMA" || hash=="#EICS" || hash=="#ORG"){ $(this).navigate({target: $(hash+'Content')}); if(window.location.hash.includes("?")) { }else{ location.href = location.href+'?'; } }else { $(this).navigate({target: $('#homeContent')}); }; }); });
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

De acuerdo con la página de referencia de MDN , las includes no son compatibles con Internet Explorer. La alternativa más simple es usar indexOf , así:

 if(window.location.hash.indexOf("?") >= 0) { ... }
over 4 years ago · Santiago Trujillo Denunciar

0

IE11 implementa String.prototype.includes, entonces, ¿por qué no usar el Polyfill oficial?

 if (!String.prototype.includes) { String.prototype.includes = function(search, start) { if (typeof start !== 'number') { start = 0; } if (start + search.length > this.length) { return false; } else { return this.indexOf(search, start) !== -1; } }; }

Fuente: fuente de relleno polivinílico

over 4 years ago · Santiago Trujillo Denunciar

0

Agregar import 'core-js/es7/array'; a mi polyfill.ts me solucionó el problema.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda