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

197
Visualizações
Chrome doesn't fire "onerror" event for "link" tag?

I am updating the theming system for a website, and I am trying to handle when a <link rel="stylesheet"> element fails to load a theme so that I can have it fallback to a default theme (as well as to identify outdated theme selections, etc.).

In Firefox, I can use the "onerror" event through jQuery before setting the href attribute, e.g. $("#myLinkElement").one("error", handleThemeLoadError).attr("href", themeUrl).

If themeUrl refers to a CSS file that does not exist (resulting in a 404), the handleThemeLoadError is called.

In Chrome, however, the onerror event is never fired. I see the 404 error in the console and network tabs, and Chrome even shows me the line of code where the attribute is set that caused the 404 error, but it will not fire an error event. I have even tried $("#myLinkElement").get(0).onerror = function() { ... }, and I've also tried setting the href attribute to both null and undefined before setting it to the actual URL.

Is there some other way to catch stylesheet load errors in Chrome, or am I completely out of luck?

about 4 years ago · Juan Pablo Isaza
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