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

147
Visualizações
Function not running during the load event of the document

I am writing a chrome extension, that has this content_script. I have written 3 functions to be triggered by 2 respective events - The double Click and Load function.

The Double Click event executes the function written for it, but, the load function or onload function are not executing their respective functions.



$("*").dblclick(function(){

    alert("Double Click");     
 
 })
 



document.addEventListener ("onload", myMain, false);

function myMain (evt) {
    alert("On Load");
}


document.addEventListener ("load", myMain, false);

function myMain (evt) {
    alert("Load");
}


about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Using jQuery, here is my understanding of desired events :

$(window).on('load', function() {
    alert('Loaded');
});

$(document).ready(function() {
    alert('Ready');
});

$(window).on('dblclick', function() {
    alert('Double click');
});

The difference between event 'load' and 'ready' is :

  • 'Load' is triggered when your page is completely loaded (images, charts ...).
  • 'Ready' is triggered when your page script's is safe to manipulate.

Just check jQuery documentation for event on document loading : https://api.jquery.com/category/events/document-loading/

There is no event to trigger a document 'onload'.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use the DOMContentLoaded event in JS to achieve this. Like this:

window.addEventListener('DOMContentLoaded', myMain);

function myMain (evt) {
    alert("Load");
}

Hope that's how you wanted it to work.

You can check here for more info - DOMContentLoaded Event

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