If you want to scroll the contents of an iframe to the top, the following should help you.
You will need 2 things first:
- Add link to C: \ Program Files \ Microsoft.NET \ Primary Interop Assemblies \ Microsoft.mshtml.dll
- edit the tag
<iframe>
so that it has an identifier, for example:id="something"
Finally, the code:
HtmlElement ele = webBrowser1.Document.GetElementById("something");
mshtml.HTMLIFrameClass frame = ele.DomElement as mshtml.HTMLIFrameClass;
if (frame != null)
{
mshtml.HTMLDocumentClass doc = frame.document as mshtml.HTMLDocumentClass;
if (doc != null)
{
object i = 0;
mshtml.HTMLWindow2Class win = doc.frames.item(ref i) as mshtml.HTMLWindow2Class;
if(win != null)
win.scrollTo(0, 0);
}
}