Questions tagged [ihtmldocument2]

The IHTMLDocument2 interface inherits from the IDispatch interface and is used to get information about the document and modify the HTML elements and the text in that document

The IHTMLDocument2 interface gets information about the document, and examines and modifies the HTML elements and text in the document.

Source - Official Documentation

90 questions
6
votes
4 answers

Unable to use IHTMLDocument2

$wc = New-Object System.Net.WebClient $DownloadString = $wc.DownloadString("http://www.example.com") $HTML = New-Object -ComObject "HTMLFile" $HTML.IHTMLDocument2_write($DownloadString) Server script runs on Major Minor Build Revision ----- …
5
votes
3 answers

MSHTML tutorial

I want to learn some basics about MSHTML, like how to use IHtmlDocument and IHtmlDocument2 interfaces. I searched for quite a while, but can not find out a tutorial for beginners. Could anyone recommend something to read? EDIT: I prefer to use C#.
George2
  • 44,761
  • 110
  • 317
  • 455
5
votes
1 answer

how to get an IHTMLElementCollection obj which composed of several IHTMLElements?

guys: I got a problem about "how to get an IHTMLElementCollection obj which composed of several IHTMLElements" in object-pascal programming , my codes below: function TExDomUtils.GetElementsByClassName(vDoc:IHTMLDocument3;…
MarcoLin
  • 53
  • 1
  • 4
5
votes
1 answer

Getting return value from Javascript in C# Webbrowser control WPF

I made JavaScript injection into WebBrowser control in C# (System.Windows.Controls.WebBrowser) such that, IHTMLDocument2 webdoc = (IHTMLDocument2)webBrowser1.Document; string var = File.ReadAllText("C:/.../Resources/script.txt"); object retVal…
4
votes
1 answer

How to query HTML with x XPath expression in C++?

I have a webbrowser and I use DocumentComplete to read the current document from the WebBrowser (as IHTMLDocument2). What's the easiest way to run xpath queries in that html doc? I am looking for something easy to use and lightweight. I am using…
jarkam
  • 1,538
  • 5
  • 15
  • 20
4
votes
1 answer

COM Interface versioning and inheritance

Why doesn't IHTMLDocument3, for example, inherit IHTMLDocument2? Why doesn't IAnyMicrosoftInterface(N) inherit IAnyMicrosoftInterface(N-1)? New interfaces just contain only new functions, but they don't inherit previous interface's functions. Can I…
3
votes
1 answer

What does queryCommandValue("FontSize") return?

I am trying to get the font size of selected range in a html document. I used queryCommandValue to get it. Some times it return an integer. And some times it is not. I don't know what is it. And I also tried another way to get the fontsize by…
Vichal
  • 55
  • 6
3
votes
1 answer

Invoking DOM onmousedown event in a Webbrowser from Visual Basic 6

I load an HTML document into a WebBrowser Control in Visual Basic 6. There is a link something I want to invoke the onmousedown event programatically from VB I've tried many…
noway
  • 2,585
  • 7
  • 41
  • 61
3
votes
0 answers

How to handle access violation?

Certain functions in my program get a bad pointer with a low probability. The pointer is the CComPtr m_htmldocument2 variable. Moving the m_htmldocument2 variable to a local variable causes an access violation error if…
i like cat
  • 135
  • 8
3
votes
1 answer

Access denied on switching to other frame (.Net WebBrowser, MsHTML) cross-domain Exception

i'm trying to switch for another frame (With no name or id) but getting Exception. object index = 0; var frame = (mshtml.IHTMLWindow2)workDocument.frames.item(ref index); frameDocument = (mshtml.IHTMLDocument2)frame.document; // Exception. Tried…
Leon Barkan
  • 2,676
  • 2
  • 19
  • 43
3
votes
0 answers

Why can't I modify an anchor's name in IHTMLDocument2?

I writing on a script that reads from a local HTML file, modifies DOM tree and then save. Instead of Invoke-WebRequest, using HTMLFile COM object seems the only way to do so. Rewriting to other attributes like href works like a charm. But somehow I…
user1902830
3
votes
1 answer

Detect cursor position in TWebBrowser at edit mode

I get selection range like this: var Range: IHTMLTxtRange; begin if Supports((Document as IHTMLDocument2).selection.createRange, IHTMLTxtRange, Range) end; TWebBrowser in editing. I need get position of cursor. How I can get its?
Semyon.Khmelev
  • 197
  • 1
  • 14
3
votes
1 answer

IHTMLStyleSheetRulesCollection for style tags (inline styles)

I use IHTMLDocument2 interface to retrieve IHTMLStyleSheetRulesCollection using the IHTMLDocument2::styleSheets property. It works fine for retrieving styles within