如何使用jquery从内部滚动iframe? [英] How do you scroll an iframe from within using jquery?
本文介绍了如何使用jquery从内部滚动iframe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个生成iframe的shadowbox来显示页面上的产品详细信息。因为详细信息页面可能很长,所以客户端需要一个更多按钮来向下滚动页面(显然iframe右侧的滚动条是不够的)。
I'm using a shadowbox which generates an iframe to display product details on a page. Because the details page can be pretty long, the client would like a "More" button that scrolls the page down (apparently the scrollbar on the right of the iframe isn't enough).
这是我为了让iframe滚动而尝试的代码:
Here's the code that I've tried in order to get the iframe to scroll:
$(document).ready(function()
{
$(".moreButton img").click(function() {
scrollbottom();
});
});
function scrollbottom() {
var x = 250; // this number is a temporary placeholder
var t = 500;
$("iframe").animate({ scrollTop: x }, t);
}
我也尝试使用body代替iframe但无济于事。有任何想法吗?谢谢!
I've also tried using body instead of iframe but to no avail. Any ideas? Thanks!
推荐答案
这最终起作用:
$('html,body').animate({ scrollTop: x }, t);
这篇关于如何使用jquery从内部滚动iframe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文