开发者

How to scroll an iFrame with the help of JavaScript?

开发者 https://www.devze.com 2023-01-12 16:41 出处:网络
What is wrong this way?: HTML: <iframe onload=\"scrollme(this)\" src=\"somesite.com\"></iframe>

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

精彩评论

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

关注公众号