简体   繁体   English

从iframe外部滚动iframe的滚动条

[英]scroll the scrollbars of an iframe from outside the iframe

i am opening a page inside the iframe from the same domain. 我正在同一域的iframe中打开一个页面。 i am trying to scroll the iframe content using jquery. 我正在尝试使用jquery滚动iframe内容。 but its scrolling the main browser contents (scrollbars) instead of the iframe contents. 但可以滚动浏览器的主要内容(滚动条)而不是iframe内容。

 <iframe id="scaled_frame" src="<?php echo $url;?>"></iframe>

i am using the following line to scroll the iframe content. 我正在使用以下行滚动iframe内容。

$("#scaled_frame").scrollTop(200);

how can i scroll the iframe contents. 我该如何滚动iframe内容。

Thank you so much 非常感谢

you can use this code: 您可以使用以下代码:

$("#scaled_frame").contents().find("body").scrollTop(200);
// or
$("#scaled_frame").contents().scrollTop(200);

the iframe not have content for that page you must find contents after that set scroll. iframe没有该页面的内容,则必须在该设置滚动之后找到内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM