开发者

Webkit.net scroll document programmatically

if I use Webkit.Net to display HTML in my winforms application everytime I set the DocumentText property, the document is scrolled back to the beginning.

开发者_如何学Go

How can I get the current scroll position and set it after I changed the document text?


Ok, it seems that I've overlooked the ScrollOffset property :).

I'd like to add that it is not sufficient to set it directly after updating the DocumentText property since webkit loads the document asyncronously. Therefore I have to intercept the DocumentCompleted event like:

Point p;

void UpdateDocument() {
  p=webkitBrowser.ScrollOffset;
  webkitBrowser.DocumentText = CreateNewDocument();
}

private void webKitBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
  webkitBrowser.ScrollOffset = p;
}

This works as I needed.

Thanks anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜