public WindowMain() { Browser browser = BrowserFactory.Create(); browserView = new WPFBrowserView(browser); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMNode root = document.GetElementById("root"); DOMNode textNode = document.CreateTextNode("Some text"); DOMElement paragraph = document.CreateElement("p"); paragraph.AppendChild(textNode); root.AppendChild(paragraph); } }; Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
public WindowMain() { Browser browser = BrowserFactory.Create(); browserView = new WPFBrowserView(browser); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); var myEvent = browser.CreateEvent("MyEvent"); DOMNode root = document.GetElementById("root"); DOMEventHandler domEvent = delegate(object s, DOMEventArgs evt) { if (evt.EventType == myEvent.EventType) { DOMNode textNode = document.CreateTextNode("Some text"); DOMElement paragraph = document.CreateElement("p"); paragraph.AppendChild(textNode); root.AppendChild(paragraph); } }; root.AddEventListener(myEvent, domEvent, false); Thread.Sleep(3000); root.DispatchEvent(myEvent); } }; Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }