Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

0

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

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda