In a site I am working on two of the pages have an iframe being loaded.

<IFRAME id="someid" src="http://www.trailblz.info/barkleydean/signup.aspx?rd=http://www.senatorbarkley.com/signup-thank-you.htm" width="700" height="1400" frameborder="0" scrolling="No" style="position: relative; width: 700px; height: 1400px" target="_blank"> </IFRAME>

This works fine but the "Thank you" page loads at the top of the frame but the browser window is at the bottom of the page. Is there a way to make the "Thank you" page scroll to the top when the "Thank you" page is loaded?

I have tried many different things but none work.

Right now I have to put a white spacer in before the thank you message to make it go to the bottom of the page so it can be seen.

Thanks in advance.

Recommended Answers

All 4 Replies

Here you go!
You may try this 1 1st!

<html>
<head>
<title>AutoScrolling</title>
<script type="text/javascript">
<!-- BEGIN HIDING

window.onload = pageScroll; function pageScroll() {
window.scrollBy(0,-50);
scrolldelay = setTimeout('pageScroll()', 200); 
/* Increase this # to slow down, decrease to speed up scrolling */
} 
// DONE HIDING-->
</script>
</head>
<body>
<div>
 <iframe id="someid" src="http://www.trailblz.info/barkleydean/signup.aspx?rd=http://www.senatorbarkley.com/signup-thank-you.htm" width="700" height="1400" frameborder="0" scrolling="No" style="position: relative; width: 700px; height: 1400px" target="_self"> </iframe>
</div>
</body>
</html>

essential,
Thanks for replying. However it does not work. If I put the JavaScript code in the page that has the iframe line in it, it scrolls the form up when you try to scroll down.

If I put in in the "Thank you" page, nothing happens.

Any more ideas?

Assuming that this is your iframe page!
Code is as follows:

iframepage.html

<html>
<head>
<title>ifram Page</title>
</head>
<body>
<div>
<iframe id="someid" src="http://www.trailblz.info/barkleydean/signup.aspx?rd=http://www.senatorbarkley.com/signup-thank-you.htm#top" width="700" height="1400" scrolling="No" style="position: relative; width: 700px; height: 1400px; border: none;"> 
</iframe>
</div>
</body>
</html>

signup-thank-you.htm

<html>
<head>
<title>ThankYouPage</title>
<script type="text/javascript">
<!-- BEGIN HIDING

window.onload = pageScroll; function pageScroll() {
window.scrollTo(0,top);
scrolldelay = setTimeout('pageScroll()', 200);

} 
// DONE HIDING-->
</script>
</head>
<body>
<!-- Alternative option! pulling the page to the top using some anchor -->
<a name="top"></a>
<!-- Some ThankYouMessage! 

This code has been tested before release and its working good!

GoodLuck on your website...
 -->

</body>
</html>

Thank You. Worked at once. I do want to be able to button-control the scroll? Any hints? (omg, it's 7 years ago) lol

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>AutoScrolling</title>
<script type="text/javascript">
<!-- BEGIN HIDING

window.onload = pageScroll; function pageScroll() {
window.scrollBy(0,-50);
scrolldelay = setTimeout('pageScroll()', 600); 
/* Increase this # to slow down, decrease to speed up scrolling */
} 
// DONE HIDING-->
</script>
</head>

<body>
<div>
 <iframe id="someid" src="http://cnn.com" width="1300" height="1400" frameborder="0" scrolling="No" style="position: relative; width: 1300px; height: 1400px" target="_self"> </iframe>
</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.