Regards
Varun
public static native void gotoAnchor( String name ) /*-{
$wnd.location = "#" + name;
}-*/;
However, some browsers refresh when you do this, which means that your
GWT code would be reloaded every time. This would be prohibitively
expensive for my apps (which tend to be large), so here's another way:
// This is javascript, you'll have to convert to JSNI
function scrollToElement(elementID)
{
var theElement = $(elementID);
if(theElement != null)
{
var selectedPosX = 0;
var selectedPosY = 0;
while(theElement != null){
selectedPosX += theElement.offsetLeft;
selectedPosY += theElement.offsetTop;
theElement = theElement.offsetParent;
}
window.scrollTo(selectedPosX,selectedPosY);
}
}
Hope this helps,
Eric
As a help to future readers, I m converting it to JSNI and pasting it
here
put this code inside your native JSNI function
public static native void gotoAnchor( String elementID) /*-{
var theElement = $doc.getElementById(elementID);
if(theElement != null)
{
var selectedPosX = 0;
var selectedPosY = 0;
while(theElement != null){
selectedPosX += theElement.offsetLeft;
selectedPosY += theElement.offsetTop;
theElement = theElement.offsetParent;
}
$wnd.scrollTo(selectedPosX,selectedPosY);
}
}-*/;