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

164
Views
No se puede hacer que <header> y <footer> se compartan entre páginas

Traté de poner <header> y <footer> en archivos externos. En la consola, el código sale bien, pero luego el código vuelve indefinido.

Pie de página HTML:

 <footer id="footer" class="footer mt-auto py-3 bg-light"> <div class="container"> <div class="col-12 text-center"> <a style="text-anchor: middle">© 2021 AlexInCube</a> </div> </div>

principal.html

 <script>document.write(importHTMLdata("content/basement.html"))</script>

scripts.js

 function importHTMLdata(path){ $.get(path, function(html_string) { console.log(html_string) return html_string; });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

NO se recomienda tener document.write: borrará la página si se ejecuta después de cargar la página.

Solo ten esto en tu archivo js

 $(function() { // on page load const importHTMLdata = path => { // define a function taking a path $.get(path, function(html_string) { // get the path $("body")[path.indexOf("footer") != -1 ? "append" : "prepend"](html_string); // if footer call $("body").append, if not call $("body").prepend }); } importHTMLdata("content/header.html"); // load header importHTMLdata("content/footer.html") // load footer });
 <script src="scripts.js"></script>
about 4 years ago · Juan Pablo Isaza Report
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!