Если у меня есть RichTextArea, как это:
RichTextArea rta = new RichTextArea();
rta.setHTML("<p id=\"foo\">Foo</p>....<p id=\"bar\">Bar</p>");
Если я расширим класс RichTextArea, как правильно (в кросс-браузерном режиме) написать метод scrollTo()?
Ex:
class RichTextAreaExt extends RichTextArea {
...
/**
* This method should be called only when the widget has properly been attached
* @param id String the HTML element id within the RichTextArea to scroll to
*/
public native void scrollToElement(String id) /*-{
var cWin = [email protected]::getElement()().contentWindow;
var el = cWin.document.getElementById(id);
if (el) {
cWin.scrollTo(el.offsetLeft,el.offsetTop);
}
}-*/; ...
}
Кажется, это работает в некоторых браузерах, но у меня нет возможности протестировать их все, так что комментарии приветствуются!
Спасибо!