Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scrollTo 1

Status
Not open for further replies.

nickdel

Programmer
Joined
May 11, 2006
Messages
367
Location
GB
Hi, I'm trying to use the scrollTo method when a page is loaded. This appears to work but it just jumps back to the top of the page again. Same thing happens if I add the scrollTo into a hyperlink, screen appears to flicker.

This happens using both IE6 and Mozilla!

Code:
document.getElementById("Resv").style.visibility="visible";
			document.getElementById("Arrival").value = BookDate;
			document.getElementById("WeekPrice").value = WeekPrice;
			scrollTo(100,0);
 
make sure that you're doing the scrolling after the page has loaded - use the onload method to ensure this:

Code:
function myScroll() {
   window.scrollTo(100, 0);
}
window.onload = myScroll;

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
and if you're incorporating it into a link, make sure you have the return false:

Code:
<a href="#" onclick="window.scrollTo(100, 0); return false;">Scrolly</a>



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
cLFlaVA, you hit the nail on the head with your suggestion. It was the return false I was missing!

Many thanks to you both

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top