1、获取iframe的窗口对象
var iwin = document.getElementById('iframe1').contentWindow;
2 、获取iframe的窗口document对象
var doc = iwin.document;
3、调用iframe window对象的scroll方法
iwin.scroll(0,doc.body.scrollHeight);
scroll两个参数为x,y轴的滚动量
doc.body.scrollHeight为iframe页面的高度(包含未显示的部分)
一个综合应用例子如下:
代码如下:
html代码
- Chapter 1In which a dragon is seen
- Chapter 1In which a knight is summoned
- Chapter 1In which a proncess is disappointed
- Chapter 1In which a dragon is seen
- Chapter 1In which a dragon is seen
- Chapter 1In which a dragon is seen
- Chapter 1In which a dragon is seen