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

140
Views
No puedo obtener la altura de desplazamiento de IFrame en HTML/JavaScript

Tengo un código HTML simple como este:

 <!DOCTYPE html> <html> </head> <script> function func() { var x = document.getElementById("frm").contentWindow.document; document.getElementById("val").innerHTML = "scrollHeight is: " + x.documentElement.scrollHeight; } </script> </head> <body> <button id="val" onclick="func()">getScrollHeight</button> <br> <br> <iframe id="frm" src="https://www.wikipedia.org/" width="100%"></iframe> </body> </html>

Tengo un problema con el código anterior:

Cuando borro el atributo "src" de IFrame(src="") y luego hago clic en el botón "getScrollHeight", muestra un número (en mi navegador muestra 150. El valor no es importante), pero cuando completo el atributo "src" con una dirección web (por ejemplo, src="https://www.wikipedia.org/") y luego haga clic en el botón, no muestra nada. ¿Por qué pasó esto? ¿Por qué no puedo obtener la altura de desplazamiento cuando el IFrame tiene contenido?

Mi navegador es Chrome (también edge).

Gracias por cualquier sugerencia.

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!