mshtml

Saving webpage content using webbrowser IHTMLDocument interface

跟風遠走 提交于 2020-01-06 06:24:09
问题 We need to save the complete web page including img, javascript, css and html using ATL webbrowser (IHTMLDocument) control, using IHTMLDocument2::get_all() method we have saved .html file but now how do we get external files such as .css, javascript and image files please help us with methods that internet explorer or firefox used to save the web page locally. Thanks, Ramanand. 回答1: I think this will be a rather manual task: You can get a grip on the stylesheets by using the IHTMLDocument2:

Access a span inside iframe using mshtml

我们两清 提交于 2020-01-04 07:18:51
问题 Im creating an IE BHO and trying to access a page that has multiple iframe tags. How to access the text in a span with id="messageText-txt" which is inside a specific iframe with name="isolatedWorkArea" and id="isolatedWorkArea" using mshtml. I tried the following options but none of them returns me the text. Any idea? Option 1: void BrowserEvents_NavigateComplete2(object pDisp, ref object URL) { SHDocVw.InternetExplorer currentIEWin = pDisp as SHDocVw.InternetExplorer; mshtml.IHTMLDocument2

Access a span inside iframe using mshtml

旧街凉风 提交于 2020-01-04 07:18:12
问题 Im creating an IE BHO and trying to access a page that has multiple iframe tags. How to access the text in a span with id="messageText-txt" which is inside a specific iframe with name="isolatedWorkArea" and id="isolatedWorkArea" using mshtml. I tried the following options but none of them returns me the text. Any idea? Option 1: void BrowserEvents_NavigateComplete2(object pDisp, ref object URL) { SHDocVw.InternetExplorer currentIEWin = pDisp as SHDocVw.InternetExplorer; mshtml.IHTMLDocument2

How to set entire HTML in MSHTML?

吃可爱长大的小学妹 提交于 2019-12-24 18:58:54
问题 How to set entire HTML in MSHTML? I am trying using this assignment: (Document as IHTMLDocument3).documentElement.innerHTML := 'abc'; but I got the error: "Target element invalid for this operation" I've also tried using (Document as IHTMLDocument2).write but this form only adds HTML into the body section, and I need to replace all the HTML source. Does somebody have any idea of how I do this? Thanks in advance. 回答1: Here's some of my old code, see if it helps you: type THackMemoryStream =

How to set Content-Type of a Webbrowser Control?

隐身守侯 提交于 2019-12-24 08:24:47
问题 Is it possible to set the Content-Type of a document in a webbrowser control? For example how can I show an XML document rendered as XML in a webbrowser control by using DocumentText? 回答1: Try add an extension to your IMoniker::GetDisplayName implementation. This will cause the URL moniker to look under HKEY_CLASSES_ROOT.??? keys for mime types. Then you can use the webbrowser's documen's IPersistMoniker interface to load the moniker. 来源: https://stackoverflow.com/questions/2570592/how-to-set

How do I use MSHTML in VB.NET?

老子叫甜甜 提交于 2019-12-23 11:53:46
问题 In the answer to question #56107, Erlend provided this sample c# code: using mshtml; ... object[] oPageText = { html }; HTMLDocument doc = new HTMLDocumentClass(); IHTMLDocument2 doc2 = (IHTMLDocument2)doc; doc2.write(oPageText); I'd like to use mshtml in VB.NET, but the IDE doesn't recognize this: Imports mshtml What additional steps do I need to take to use MSHTML in VB.NET? 回答1: Found an answer to my own question: MSHTML in ASP.NET If you are interested, here is the solution based on VB

How to disable Javascript in mshtml.HTMLDocument (.NET)

て烟熏妆下的殇ゞ 提交于 2019-12-23 09:32:09
问题 I've got a code like this : Dim Document As New mshtml.HTMLDocument Dim iDoc As mshtml.IHTMLDocument2 = CType(Document, mshtml.IHTMLDocument2) iDoc.write(html) iDoc.close() However when I load an HTML like this it executes all Javascripts in it as well as doing request to some resources from "html" code. I want to disable javascript and all other popups (such as certificate error). My aim is to use DOM from mshtml document to extract some tags from the HTML in a reliable way (instead of bunch

Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLElementCollection

白昼怎懂夜的黑 提交于 2019-12-23 05:06:00
问题 Am trying to use mshtml to fill a form on vb.net through the webbrowser control, Dim doc As MSH.IHTMLDocument2 = DirectCast(wbMain.Document.DomDocument, MSH.IHTMLDocument2) Dim buttons As MSH.HTMLElementCollection = doc.getElementsByTagName("button") Dim Inputs As MSH.HTMLElementCollection = doc.getElementsByTagName("input") but i get the following error Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLElementCollection'. This operation failed because the

NullReferenceException with System.Windows.Controls.WebBrowser WPF

心已入冬 提交于 2019-12-23 03:29:09
问题 I have a C# WPF application with a web browser control (System.Windows.Controls.WebBrowser) called wB. It is supposed to display a local html file, and some information parsed from it. I get the a NullReferenceException as it says body is null in the last line (IHTMLElementCollection data = hDoc.body.children as IHTMLElementCollection) with the following code: wB.Navigate(new Uri(file, UriKind.Absolute)); HTMLDocument hDoc = (HTMLDocumentClass)wB.Document; IHTMLElementCollection data = hDoc

Any workaround to get text in an iFrame on another domain in a WebBrowser?

混江龙づ霸主 提交于 2019-12-22 06:56:05
问题 You will probably first think is not possible because of XSS restrictions. But I'm trying to access this content from an application that hosts a WebBrowser , not from javascript code in a site. I understand is not possible and should not be possible via non hacky means to access this content from javascript because this would be a big security issue. But it makes no sense to have this restriction from an application that hosts a WebBrowser . If I'd like to steel my application user's