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

250
Views
Cómo obtener la altura de un Iframe después de escribir en su contenido

Estoy escribiendo el contenido de un área de texto en un iFrame, por lo que necesito establecer la altura del elemento en la página principal para mostrarlo correctamente:

 const $iFrames = $('iframe'); function iframeLoaded(iFrameID) { const iFrame = document.getElementById(iFrameID); if (iFrame) { const height = `${iFrame.contentWindow.document.body.scrollHeight}px`; iFrame.height = ''; iFrame.height = height; console.log('height:', height); } } $iFrames.each((i, frame) => { const $frame = $(frame); const ta = $frame .next('textarea'); const doc = $(frame)[0].contentWindow.document; doc.open(); doc.write(ta.val()); doc.close(); iframeLoaded($frame.attr('id')); });

Sin embargo, en este ejemplo, la constante de height siempre es 0, pero el contenido se carga correctamente. ¿Dónde me estoy equivocando?

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!