在Phonegap中设置iFrame高度

时间:2012-12-11 17:17:45

标签: css cordova iframe height

我正在开发一个需要使用iframe的Phonegap项目。

iframe加载正常,但在Safari Developer Inspector的“计算样式”中覆盖设置高度(由height属性或CSS内联)。相反,高度会自动设置为匹配,但是它包含的内容要求高(因此永远不会滚动)。当我浏览iframe中的不同链接时,高度会发生变化。

有没有一种已知的方法呢?

1 个答案:

答案 0 :(得分:1)

我使用javascript / jQuery做过一次。这对你有用吗? jsFiddle

HTML

<iframe id="iframeId" marginheight="0" marginwidth="0" align="top" frameborder="0" scrolling="no"></iframe>​

CSS

#iframeId {
  overflow: hidden !important;
 -ms-zoom: 0.4; 
 -moz-transform: scale(0.4); 
 -moz-transform-origin: 0px 0; 
 -o-transform: scale(0.4); 
 -o-transform-origin: 0 0; 
 -webkit-transform: scale(0.4); 
 -webkit-transform-origin: 0 0;
}

的jQuery

$('#iframeId').attr('src', "http://webpage.com").width("1105").height("627");

不确定这是你要做的事情,但in this example,iFrame的尺寸由jQuery设置 / javascript,并允许完整框架网站显示在较小的容器中,因此缩放。

希望这会有所帮助。