一、用法:
1、页面内加入iframe
<iframe width=420 height=330 frameborder=0 scrolling=auto src=URL></iframe>
scrolling表示是否显示页面滚动条
可选的参数为auto、yes、no,如果省略这个参数,则默认为auto。
2、超链接指向这个嵌入的网页,只要给这个iframe命名就可以了。方法是<iframe name=**>,例如我命名为aa,写入这句HTML语言:
<iframe width=420 height=330 name=aa frameborder=0 src=http://www.cctv.com></iframe>
然后,网页上的超链接语句应该写为:<a href=URL target=aa>
二、自适应内容高度
以下代码放入body中:
<!-- iframe自适应高度 -->
<script>
function SetCwinHeight(){
var bobo=document.getElementById("content"); //iframe id
if(document.getElementById){
if(bobo && !window.opera){
if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
bobo.height = bobo.contentDocument.body.offsetHeight;
}else if(bobo.Document && bobo.Document.body.scrollHeight){
bobo.height = bobo.Document.body.scrollHeight+30;
}
}
}
}
</script>