iframeの高さを取得する下記のようなソースを入れています。
何も中身がないときはheight: 0;にしたいのですが、中身が無い時でも高さが150px出てしまいます。
これは何故なのでしょうか?
<iframe src="" class="autoHeight" frameborder="0" style="width: 100%"></iframe> $(window).on("load",function(){ $('iframe.autoHeight').each(function(){ var D = $(this).get(0).contentWindow.document; var innerHeight = Math.max( D.body.scrollHeight, D.documentElement.scrollHeight, D.body.offsetHeight, D.documentElement.offsetHeight, D.body.clientHeight, D.documentElement.clientHeight ); $(this).removeAttr("height").css('height', innerHeight + 'px'); }); });
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。