Log in

View Full Version : Scroll Iframe Down page



ojsimon
02-16-2008, 02:01 PM
On my site i am displaying an external site in a frame e.g (www.wikipedia.org), i would like it to automatically scroll down half the page or a quarter of the page down, i cannot use anchors because it is a dynamic page, how can i do this.

Thanks

postrational
02-23-2008, 06:18 PM
This question can be addressed using JavaScript. And in particular the scrollBy(int horizontal, int vertical) method.

Theoretically this code, should work (it does with Safari), but you would have to iron it out to have it work across browsers.


<body onload="window.frames['Wikipedia_Frame'].scrollBy(0, 800)">
<iframe name="Wikipedia_Frame" id="Wikipedia_Frame" src="http://en.wikipedia.com" width="800" height="300">
Sorry, your browser doesn't support iframes.
</iframe>
</body>

The window.frames['Wikipedia_Frame'].scrollBy(0, 800) call scrolls the Wikipedia_Frame down by 800 pixels.