PDA

View Full Version : problem with scrollto()



Dredon
04-25-2007, 06:10 PM
hi everyone

i have this code in some page i made

<html>
<body onload="window.scrollTo(500,500)">
<iframe src="http://somewebpage.com" width="250" height="150"></iframe>
</body>
</html>

and it's not go to the coordinate on the onload event :\ anyone know how i can fix that?

what i want to do is webpage that open another webpage in specific coordinates.

jscheuer1
04-26-2007, 07:00 AM
The code for the page in your post says to scroll the window to 500x500. But, the only thing on the page is an iframe of the dimensions 250x150. If the window did scroll to 500x500, there would be nothing there. You seem to want to scroll the iframe. If it is on another domain, that gets tricky. If it is on your domain, just put the body onload event on the page in the iframe.

I think it is on another domain. If so, you need another page.

Top page:


<html>
<body>
<iframe src="somepage.htm" width="250" height="150"></iframe>
</body>
</html>

somepage.htm:


<html>
<body onload="window.scrollTo(500,500)">
<iframe src="http://somewebpage.com" width="100%" height="30000" frameborder="0" scrolling="no"></iframe>
</body>
</html>

pcbrainbuster
04-26-2007, 07:03 AM
Well it is easy to do it in an iframe too -

<html>
<body onload="document.getElementById('iframe').scrollTo(500,500)">
<iframe id="iframe" src="http://somewebpage.com" width="250" height="150"></iframe>
</body>
</html>

Make sure the page height and width is over 500...

jscheuer1
04-26-2007, 07:08 AM
Well it is easy to do it in an iframe too -

<html>
<body onload="document.getElementById('iframe').scrollTo(500,500)">
<iframe id="iframe" src="http://somewebpage.com" width="250" height="150"></iframe>
</body>
</html>

Make sure the page height and width is over 500...

I don't think that will work even on the same domain and it certainly will not work across domains. To scroll the iframe, I think it needs to be addressed as a window object, not as a page element. Even if you do it as a window object, it must be on the same domain. Otherwise, it is a security violation.