If I have an RichTextArea like this :
RichTextArea rta = new RichTextArea();
rta.setHTML("<p id=\"foo\">Foo</p>....<p id=\"bar\">Bar</p>");
If I extend the RichTextArea class, how would be the proper way (cross-browser wise) to write a scrollTo() method?
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);
}
}-*/; ...
}
This seems to work in some browsers, but I don't have all of them to test, so inputs are welcome!
Thanks!