HtmlElement script = wf.WebBrowser.Document.CreateElement("script"); script.SetAttribute("type", "text/javascript"); script.SetAttribute("text", "function _func(){return document.body.scrollHeight}"); HtmlElement head = wf.WebBrowser.Document.Body.AppendChild(script); var height2 = wf.WebBrowser.Document.InvokeScript("_func");