How can I get a firing/clicking event in XUL scrollbar. I have a box
where, when I refresh the content using DOM creation and deletion, I
want to have user get the top of the page for every DOM refresh.
I tried many tricks with the js like window.scrollTo, etc.. no luck
so
far.
Appreciate if you have solution/trick for above issue.
thanks
http://books.mozdev.org/html/mozilla-chp-2-sect-2.html#mozilla-CHP-2-SECT-2.5
Except SizeToContent, home no other option is working for window. Not
sure if anyone of you hit this issue before? I am using xr 1.9.1.4
thanks
window.scrollTo(0,0) works for me. See also:
https://developer.mozilla.org/en/DOM/window.scroll
I suspect you're not getting the proper window if it's not working for you.
Eric
Here is my code. Tried different versions of it as well - no luck. Can
you post your sample, perhaps I might be missing something real
basic.
I am yet to try the xpcom methods however keeping it to the simple
cmds like scrollTo or scroll or moveTo are not working.
thanks
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="Test"
windowtype="app"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
>
<box flex="1" class="test" id="test_id" style="background-color:
white ;text-align: center; overflow:scroll">
<vbox>
<button onClick="scroll(100, 100);">click to scroll down 100
pixels</button>
</vbox>
</box>
</window>
The problem is that |scroll(100,100)| is being called on your <window/>, not
the browser window. You need to call scroll() on the correct window. Try:
var wnd = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow("navigator:browser");
wnd.scroll(100, 100);
><box flex="1" class="test" id="test_id" style="background-color: white; text-align: center; overflow: scroll">
>
>
To scroll an individual overflowing element use its scrollLeft and
scrollTop properties.
--
Warning: May contain traces of nuts.
So key is to apply scroll operations to only to the elements which
have the overflow:scroll set.