Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

555
Views
¿Cómo componer el código html dentro de la función onload ()?

Dentro del cuerpo tengo 3 div: menú, submenú, detalle. Estoy usando el script load_menu() en el menú div para cargar el código html en el submenú div. Estoy usando el script load_data() en el submenú div para cargar el código html para detallar div. En ambos scripts utilizo el método fetch. Hasta ahora todo funciona bien.

Me gustaría cargar el primer elemento del submenú después de cargar el submenú div, usando la función onload(). No sé cómo reformar la línea del submenú en la sintaxis adecuada en la función onload().

Lo siguiente son partes de mi código:

  1. definicion de scripts:

 <script> function load_menu(htmname) { fetch(htmname /*, options */) .then((response) => response.text()) .then((html) => { document.getElementById("submenu").innerHTML = html; }) .catch((error) => { console.warn(error); }); } function load_data(htmfile) { fetch(htmfile /*, options */) .then((response) => response.text()) .then((html) => { document.getElementById("detail").innerHTML = html; }) .catch((error) => { console.warn(error); }); } function loadfirst() { /* load_data("./iNat_files/PID297.html"); ???? */ } </script>

 /* menu item executed onclick */ <li><a href="#submenu" onclick=load_menu("./iNat_files/P_menu.html") onload="loadfirst()">Plants</a></li> /* the first submenu item to fetch - to be adapted and reformed for use with onload() */ <li><a href="#detail" onclick=load_data("./iNat_files/PID297.html")># 297: = Centaurea crocodylium</a></li>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!