Question : Javascript to force a "scroll to the top of page" upon page load

Hi

I'm working on a website where I need to ensure that whenever a certain page is loaded the page scrolls up to the top of the page.

I'm dealing with an Iframe issue and without going into the miserable details, it would be great if a javascript (or css) can be set up to automatically force the page to scroll to the top.  (I don't want there to be a button to hit -- I want it automatic.)

Is this possible?

Thanks,

Rowby

Answer : Javascript to force a "scroll to the top of page" upon page load

"(NOTE:  the iframe page is on a server I do not have access to."

Then you can't make any adjustments in the page code.  Any page you load into an iframe will automatically load to the top.  I don't see how or why you are having this problem?  If it is just a matter of reloading the iframe contents, the user right clicks on the iframe and chooses, reload (or refresh) this iframe.

You could try --

<iframe  id="blockrandom" name="contentframe" src="https://www.foobar.com" onClick="window.scrollTo(0,0);"  </iframe>

But the user will still have to click on that area.  In the above, you can substitute onMouseOver for onClick, but that will be kind of disastrous -- the person will never be able to scroll down the page !!!
Random Solutions  
 
programming4us programming4us