嘿,我有一个iframe,我正在使用以下脚本调整其内容大小。我想用两个按钮显示和隐藏这个iframe,但是当其隐藏iframe的宽度和高度时不计算,所以当我单击显示按钮时它不显示,因为宽度和高度仍然设置为0.显示和隐藏大小为内容的iframe
我很新jQuery和JavaScript,所以帮助将不胜感激。
<script language="JavaScript">
$(document).ready(function(){
$(".ShowFrame").click(function(){
$("#iframe1").show();
});
$("#iframe1").hide();
});
function autoResize(id){
var newheight;
var newwidth;
if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
}
document.getElementById(id).height= (newheight) + "px";
document.getElementById(id).width= (newwidth) + "px";
}
</script>
非常感谢! Gawd stackoverflow拥有! – salmon 2010-09-09 09:06:23