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.
精彩评论