Intento ajustar automáticamente la altura de los iframes de acuerdo con el contenido dentro de las pestañas de Avada (Tema WP).
Encontré aquí , en stackoverflow, este código:
Antes de cerrar la etiqueta </body> :
<script type="text/javascript"> function getDocHeight(doc) { doc = doc || document; // stackoverflow.com/questions/1145850/ var body = doc.body, html = doc.documentElement; var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); return height; } function setIframeHeight(id) { var ifrm = document.getElementById(id); var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document; ifrm.style.visibility = 'hidden'; ifrm.style.height = "10px"; // reset to minimal height ... // IE opt. for bing/msn needs a bit added or scrollbar appears ifrm.style.height = getDocHeight( doc ) + 150 + "px"; ifrm.style.visibility = 'visible'; } document.getElementById('ifrm').onload = function() { // Adjust the Id accordingly setIframeHeight(this.id); }En cada pestaña:
<iframe id="ifrm" src="https://TheTabUrl.com"></iframe>Me funciona pero solo en la primera pestaña. Tengo 4 iframes en 4 pestañas diferentes en la misma página. Por favor, ¿alguna idea sobre la forma de hacerlo funcionar?
Gracias por su tiempo por adelantado. Saludos