views:

314

answers:

2

How can I get an iframe such that when it loads up, it loads up with the page inside scrolled down by a fixed amount (say 100px)?

I have so far:

<iframe src="http://news.bbc.co.uk/1/hi/uk/7459669.stm" scrolling="no" width=500px height=500px></iframe>

but it loads up with the bbc.co.uk page inside at the top left when I actually want it to load up scrolled part way down (that is the page inside the iframe scrolled down, not the page containing the iframe).

Anyone know how to do this?

A: 

You can not do this. Browser security restrictions will prevent you from accessing the "inside" of that frame completely. If the frame src was from the same domain as the containing page, then you could add an onload handler that set myiframe.contentDocument.body.scrollTop = 100;.

Jakob Kruse
+1  A: 

Its not exactly what you are looking for but you could set the URL to load scrolled to a particular element if you know that an element with that ID will always be on the page. Something like this:

http://news.bbc.co.uk/2/hi/uk_news/7459669.stm#mediaAsset

HTH

DannyLane