How Do You Scroll An Iframe From Within Using Jquery?
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 scroll
Solution 1:
Like this: (Tested)
$("iframe").contents().children().animate({ scrollTop: x }, t);
Solution 2:
Create a function in the parent javascript like this:
functionscrollToPoint(top) {
$("html, body").animate({ scrollTop: top }, "slow")
}
and call that function within the iframe like this:
window.parent.scrollToPoint(top);
It should work in chrome, not tested in firefox yet
Solution 3:
This ended up working:
$('html,body').animate({ scrollTop: x }, t);
Solution 4:
In Chrome I had to specifically select the body element:
$('#my-iframe').contents().find('body').animate({scrollTop:90},500);
Post a Comment for "How Do You Scroll An Iframe From Within Using Jquery?"