...

View Full Version : scroll to top with iFrame and anchor link



ChitownE
05-18-2006, 06:08 AM
Been beating my head against the wall on the one for a while now. I have a page with an iFrame. The src of the iFrame is a page with an anchor link. When the iFrame src URL jumps to the #anchor, the outer window scrolls down as well. Ugh. Here's what I'm talking about:

http://www.singley.org/test/test.html

I tried adding a self.scrollTo(0, 0) line of javascript at the bottom of the parent page, and on the onload of the iFrame, but neither worked. If I add that code to a link or button, however, I can scrollTo the top of the page onClick no problem.

So, anyone know how I can scroll the outer window back to the top when the page loads? Thanks!

otaku149
05-18-2006, 05:55 PM
Hi ChitownE,

Add a setTimeout like below:


<br>
<br>
Page Bottom
<script>
setTimeout("self.scrollTo(0,0)",1);
</script>
</body>

Mr J
05-18-2006, 10:30 PM
Take a look here, this may help

www.huntingground.freeserve.co.uk/webplus/iframes/iframe_anchor_dir.htm



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum