how to link with page in gwt without update history stack?

46 views
Skip to first unread message

mars

unread,
Mar 13, 2012, 5:29:14 PM3/13/12
to Google Web Toolkit
hi,

my gwt page has link within itself, like normal html page
<a href="#b">B</a>
point to
<a name="b"></a>
<h3>B</h3>

within the same page, but i don't want to update the
history stack by appending '#b' to the end of url. how can
i do that? I used anchor instead of hyperlink.

thanks.

dodo dard

unread,
Mar 14, 2012, 1:45:49 PM3/14/12
to google-we...@googlegroups.com
I don't know if we can do that, because when one click on a link, browser native implementation is  to update history stack. It doesn't go through GWT.


================

Jens

unread,
Mar 14, 2012, 2:24:34 PM3/14/12
to google-we...@googlegroups.com
I think its only possible if you do the scrolling yourself and do not rely on the <a name=...> tag.

You can probably do something like (untested):

anchor.addClickHandler(new ClickHandler() {
  public void onClick(ClickEvent event) {
    Widget jumpTo = getWidgetYouWantToScrollTo();
    jumpTo.getElement().scrollIntoView(); //Version 1
    scrollPanel.setVerticalScrollPosition(jumpTo.getElement().getOffsetTop()); //Version 2
    Window.scrollTo(0, jumpTo.getElement().getOffsetTop()); //Version 3
  }
});



-- J.
Reply all
Reply to author
Forward
0 new messages