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

Neil neil at parkwaycc.co.uk
Mon Aug 2 15:07:18 EDT 2004


Jaap Haitsma wrote:

>Neil wrote:
>  
>
>>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?
>  
>
Add a load event handler. Search navigator.js for loadEventHandlers for 
an example.


More information about the Project_owners mailing list