开发者

How to scroll an iFrame with the help of JavaScript?

What is wrong this way?:

HTML:

 <iframe onload="scrollme(this)" src="somesite.com"></iframe>

Javascript:

 function scrollme(ob) {
     o.scrollTop = 1开发者_开发知识库00;
 }


An iframe doesn't scroll. The viewport is always the size of the iframe, so there is no overflow that can scroll.

If you want the page inside the iframe to scroll, you have to make the document scroll. However that is only possible if the page shown in the iframe is from the same domain.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜