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

148
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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