-1

i just wanted an iframe to always have the height of its content. i thought it would be as easy as "overflow:visible" but of course not. then i found codes to actually make this work. but of course they dont work if the content is from another domain... same origin policy and what not.

i cant edit the content im embedding, or whatever its called. i just want the frame to be the same size. i thought this is a pretty basic expectation.

actually, youtube somehow does this with the comments section, but maybe they do cross domain communication or something.

this is really all i need. something similar to an iframe that can adjust its height to the content

code for the iframe:

and the code is this: var f = document.createElement('iframe');
f.src = 'https://apis.google.com/u/0/wm/4/_/widget/render/comments?usegapi=1&first_party_property=YOUTUBE&href=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D' + location.href.match(/v=(.+?)([#&]|$)/)[1];

var e = document.querySelector('#distiller-spinner');
e.parentNode.appendChild(f, e);
e.parentNode.removeChild(e);

it makes the actual comments section on every youtube watch page load instantly, except, the frame's height is never right, so i removed the f.height part from the code

1 Answers1

0

Have you tried using an iframe and setting the height attribute to 100%. This can be done directly in the iframe element. Make sure the html and body elements are also set to 100% for this to work properly.

<iframe style="height:100%;">
Ally Rippley
  • 525
  • 2
  • 6