Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Iframe Scrollto(x,y)

Iframe Scrollto

1:57 am on Dec 23, 2008 (gmt 0)

New User

5+ Year Member

joined:June 23, 2008
votes: 0


I'm googling and googling and can't get it working! :(

I have a iframe frome a external website.
This iframe I want to begin at 200 px on x and 20 px on y..

So i thought, this can be done.. well it should be but i tried different java codes.. But so far no luck!

So i found i have to use window.scrollTo(200,20)
document.frames['IFRAME_ID_HERE'].scrollTo(x, y);

All my code is mest up now :( so can't show what i have now makes no sense anymore..

Is it possible?
I will post my code when i cleaned it up!

3:41 pm on Dec 23, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

Why can't you just use page anchors and dispense with the Javascript? If the source code has any anchors or even ID'ed elements, this should work.

<li><a href="iframe.html#help">Help</a></li>
<li><a href="iframe.html#contact">Contact</a></li>
<li><a href="iframe.html#about">About</a></li>
<iframe src="iframe.html"></iframe>

In iframe.html:

<a name="help" id="help"></a>
<p>Paragraphs or lists on help . . . </p>
<a name="contact" id="contact"></a>
<p>Paragraphs or lists on contact info . . . </p>
<a name="about" id="about"></a>
<p>Paragraphs or lists on about topic . . . </p>

It doesn't require anchors. If it's coded with ID elements,

<h3 id="help-head">Help</h3>

You should still be able to do

<li><a href="iframe.html#help-head">Help</a></li>