Reputation: 21
I have an iframe in my page and i want to create a button that when i press it the page in the iframe scrolls down...
Can anyone help?
Upvotes: 0
Views: 4737
Reputation: 21
$("#scrolldownbut").click(function()
{
var q=$("#theframe").scrollTop();
q=q+100;
$("#theframe").scrollTop(q);
return false;
});
This code works fore me. The frame's id and name is theframe
and the scrollbut
is a div to scroll down the frame. Notice: the frames width and height must not be in percentage (thats what i wanted to do) because in percentage it doesnt work.
Upvotes: 1
Reputation: 177786
To use flesler, you can do
<div id="pane-target" class="pane">
<iframe style="width:1000px; height:1000px" src="MyInformation.html"></iframe>
</div>
Upvotes: 0
Reputation: 1785
You can scroll an iFrame using Javascript with the scrollTo and scrollBy methods. This has been discussed here before, and the answer there has a simple example:
How to Scroll an iFrame using javascript
Upvotes: 0
Reputation: 668
I believe this article answers it better than I ever would - http://flesler.blogspot.com/2007/10/jqueryscrollto.html
Let me elaborate:
I've used flesler's library before for the same purpose(scrolling an iFrame inside a facebook application, same deal more or less) and it's honestly beautiful. The linked article explains several detailed situations in how you'd use scrollTo, and it works nicely.
Upvotes: 0