动态设置IFrame的宽和高,隐藏的时候设置宽和高为0,显示时,设置正常值!
<iframe id = kk name="I1" border="1" frameborder="1" width="0" height="0"></iframe>
<p onclick = 'a(2)'>显示</p>
<p onclick = 'a(1)'>隐藏</p>
<script>
function a(i)
{
if (i == 1)
{
document.all.kk.style.width = 0;
document.all.kk.style.height = 0;
}
else
{
document.all.kk.style.width = 100;
document.all.kk.style.height = 100;
}}
</script>
<iframe id = kk name="I1" border="1" frameborder="1" width="0" height="0"></iframe>
<p onclick = 'a(2)'>显示</p>
<p onclick = 'a(1)'>隐藏</p>
<script>
function a(i)
{
if (i == 1)
{
document.all.kk.style.width = 0;
document.all.kk.style.height = 0;
}
else
{
document.all.kk.style.width = 100;
document.all.kk.style.height = 100;
}}
</script>
display = "none"
<iframe id = kk name="I1" border="1" frameborder="1" width="100" height="100" style="display :none"></iframe> ---- 隐藏<iframe id = kk name="I1" border="1" frameborder="1" width="100" height="100" style="display :block"></iframe> ---- 显示
function show(ifm){
obj = document.all[ifm];
display=obj.style.display;
obj.style.display=(display=="block")?"none":"block";
}
</script>
<input type=button onclick="show('kk')" value="Show/Hide">
<iframe id=kk src="http://www.csdn.net" border="1" frameborder="1" width="100" height="100" style="display:none"></iframe>