2010-05-04 94 views

回答

1

發現其他人可能尋找它的答案:

window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) 
    .getInterface(Components.interfaces.nsIWebNavigation) 
    .QueryInterface(Components.interfaces.nsIDocShellTreeItem) 
    .rootTreeItem.QueryInterface(Components.interfaces.nsIInterfaceRequestor) 
    .getInterface(Components.interfaces.nsIDOMWindow) 
    .gBrowser.selectedBrowser.contentWindow.scrollY 
0

我認爲scrollTopscrollHeight屬性應該可以幫到你。您可以將其與clientHeight屬性結合使用。

僞代碼:

scrollPercent = 100 
if(clientHeight <= scrollHeight) { 
    scrollPercent = (scrollTop/(scrollHeight - clientHeight)) * 100 
} 
+0

下面將返回我的罰款客戶高度: window.QueryInterface(組件.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow) .gBrowser.selectedBrowser.clientHeight 相同的對象上調用。然而scrollHeight屬性總是返回等於clientHeight的值,並且調用scrollTop的總是返回0 。 道歉的格式:/ – user332849 2010-05-07 07:11:01