View Full Version : Scrolling the content of iFrames
06-27-2006, 02:53 PM
I would like the document within the iFrame to scroll to a specified position on load, and have 2 buttons in the main document that scroll the document within the iFrame up or down.
I have tried to use the scrollTo() and scrollBy() functions to achieve this, but when I try to test it, nothing happens. :(
Note: I don't want the iFrame's scrollbars visible.
Any suggestions? Is this even possible?
is there the page loaded in iframe belong to the same domain as the parent page? Otherwise it is not possible, as cross-domain manipulation is forbidden by default, for obvious security reasons.
06-27-2006, 03:17 PM
That explains why it wasn't working; it's not in the same domain. :(
Thanks for the help.
Is there any other way I could scroll the content without using scrollbars, or perhaps have a button to show/hide the scrollbars?
You may use the scrolling HTML attribute for the iframe...
<iframe scrolling="no" ........
but, would that be wise? If the content is much higher, the user will not be able to see the whole content...
CSS woun't work for IE, I reckon.......
06-27-2006, 03:28 PM
With either of those methods, is it possible to toggle the scrollbars on and off?
EDIT: The page that I wish to display in an iFrame contains content that does not need to be viewed, but it needs to be viewable (ads, I'm not allowed to block them out). I just want a way that makes it possible to see the ads, while being as compact as possible (scrollbars take up a lot of space, and they can be annoying, which is why I would prefer not to have them).
In theory yes, using either style or setAttribute() methods. Unfortunately, IE does not follow these methods in case the page is from another domain.
06-27-2006, 03:59 PM
So there's no way to show the content of the page whilst being able to view the ads without showing the scrollbars?
EDIT: Is it possible to just show the page scrolled to a certain position, without the user being able to scroll at all [and so not be able to view the ads]?
06-27-2006, 04:18 PM
You could nest the IFRAME in say a DIV(overflow:auto;) and scroll the DIV
06-28-2006, 01:38 AM
How would I do that?
Would I be able to do what I said in the first post by doing that?
06-28-2006, 11:48 AM
Would I still set the iFrame within the DIV to the dimensions I want, or would that be done in the DIV?
I'm still a little lost as to how I would scroll the DIV, would I be able to have it without scrollbars etc. like I wanted in the first post? Please explain exactly what to do and what I could achieve.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.