[Project_owners] How to obtain the scrollbar positions of a webpage?

Neil neil at parkwaycc.co.uk
Mon Aug 2 14:06:20 EDT 2004


Jaap Haitsma wrote:

> curScrollX = tab.contentWindow.scrollX;
> curScrollY = tab.contentWindow.scrollY;
> //Let's say the position is curScrollX=100, curScrollY=100
>
> tab.webNavigation.loadURI(tab.reloadEveryURL, loadFlags, null, 
> entry.postData, null);
> // This loads a page and we see the top of that page.
>
> log(tab.contentWindow.scrollX + ',' +tab.contentWindow.scrollY);
> // Still prints (100,100). I would expect (0,0)
> log(curScrollX + ',' +curScrollY);
> // Prints of course (100,100)
> tab.contentWindow.scrollTo(curScrollX, curScrollY);
> // Does not seem to scroll the window. Nothing happens
> log(tab.contentWindow.scrollX + ',' +tab.contentWindow.scrollY);
> // Still prints (100,100)
>
> What's going wrong here?? I don't get it

Are you waiting for the page to load?


More information about the Project_owners mailing list