[Project_owners] How to obtain the scrollbar positions of awebpage?

Jaap Haitsma jaap at haitsma.org
Mon Aug 2 15:42:54 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?

No, I thought loadURI was synchronous. How do I know when the page is loaded?

Jaap



More information about the Project_owners mailing list