0

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?

Xara
  • 21
  • 2
  • 6

4 Answers4

1
  $("#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.

Oleks
  • 31,955
  • 11
  • 77
  • 132
Xara
  • 21
  • 2
  • 6
0

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.

Ditmar Wendt
  • 668
  • 4
  • 15
  • I checked it quickly.Thank you. Do i have to download a plygin? – Xara Sep 23 '10 at 13:18
  • I would also appreciate it if you could give me an example... i didnt see anything in the link you sent me! Thanks in advance – Xara Sep 23 '10 at 13:19
  • It would be useful if you provide your code for scrolling the iframe since the example page doesn't includes an example to scroll an iframe and it seems not to work the standard way with it. – Alejandro García Iglesias Jul 31 '12 at 16:17
0

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

Community
  • 1
  • 1
Dan M
  • 1,765
  • 1
  • 11
  • 17
0

To use flesler, you can do

<div id="pane-target" class="pane">
  <iframe style="width:1000px; height:1000px" src="MyInformation.html"></iframe>
</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • «
    – Xara Sep 23 '10 at 18:04
  • scroll up and see the answer :) its the answer #4 !! – Xara Sep 25 '10 at 15:10
  • Ah - I see now it was your own comment. Thanks – mplungjan Sep 25 '10 at 16:12