Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scrollbar firing/clicking events

1 view
Skip to first unread message

Vasu

unread,
Dec 17, 2009, 4:40:29 AM12/17/09
to
Hi Guys,

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

Vasu

unread,
Dec 17, 2009, 8:12:00 PM12/17/09
to
I just tried almost all the methods that are listed here.

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

Eric Jung

unread,
Dec 19, 2009, 6:58:55 PM12/19/09
to dev-ext...@lists.mozilla.org

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

Vasu

unread,
Dec 20, 2009, 6:03:33 AM12/20/09
to
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>

Eric Jung

unread,
Dec 20, 2009, 12:14:37 PM12/20/09
to dev-ext...@lists.mozilla.org

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);

Neil

unread,
Dec 20, 2009, 4:34:17 PM12/20/09
to
Vasu wrote:

><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.

Vasu

unread,
Dec 27, 2009, 4:50:20 PM12/27/09
to
Neil, that did work. Thanks a lot. I was trying to apply scrollLeft
and scrollTop to children.

So key is to apply scroll operations to only to the elements which
have the overflow:scroll set.

0 new messages