iframe动态高度宽度变化基于内容 [英] iframe dynamic height width change based on inner content

查看:126
本文介绍了iframe动态高度宽度变化基于内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下内容的iframe:

I have iframe with content like below,

    <iframe  frameborder="no" src="http:localhost/com" id="iframe">
     <div style="height:850px;width:700px;">div text </div>
   </iframe>

这显示了使用hori的iframe。和垂直滚动,但内部内容的高度不是850px。

This shows the iframe with hori. and vertical scroll but not the height on inner content of 850px.

如何根据内容高度n宽度动态改变iframe高度。 Im使用jquery里面的内容。

how can i change the iframe height dynamiclly based on inner content height n width. Im using jquery inside the content.

其跨域js小部件,因此下面的大多数答案都会抛出允许拒绝错误

Thanxs,
Nithish

Thanxs, Nithish

推荐答案

var newHeight = $("iframe[id='iframeAutenticador']").contents().find("html").height();
$("iframe[id='iframeAutenticador']").height(newHeight);

使用此。

这篇关于iframe动态高度宽度变化基于内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆