html的内联框架如何共享父网页scrolling
时间: 2024-02-17 19:02:09 浏览: 135
可以在内联框架中添加一个属性,指定父窗口的滚动条控制内联框架的滚动,例如:
```html
<iframe src="http://www.example.com" scrolling="no" frameborder="0" width="100%" height="500" marginheight="0" marginwidth="0" style="overflow-x:hidden;" onload="this.style.height=this.contentWindow.document.body.scrollHeight+'px';this.contentWindow.document.body.style.overflow='hidden';" name="frame1" id="frame1" allowfullscreen></iframe>
<script type="text/javascript">
window.onload=function(){
document.getElementById('frame1').contentWindow.document.body.style.overflow='hidden';
var parent = window.parent;
parent.document.body.style.overflow='hidden';
}
</script>
```
在内联框架中添加了一个onload事件,使内联框架的高度自适应内容高度。同时,通过JavaScript获取父窗口并设置父窗口的滚动条属性,使内联框架能够共享父窗口的滚动条。
阅读全文
相关推荐



















