`
jgsj
  • 浏览: 1001562 次
文章分类
社区版块
存档分类
最新评论

IHTMLDocument2的所有成员、属性、方法、事件

 
阅读更多

IHTMLDocument2 Interface
Gets information about the document, and examines and modifies the HTML elements and text in the document.

IHTMLDocument2 Members

activeElement Gets the object that has the focus when the parent document has focus.
alinkColor Sets or gets the color of all active links in the document.
all Gets an interface pointer to a zero-based collection of all the elements in an HTML document.
anchors Gets an interface pointer to a zero-based collection of all the a objects in an HTML document.
applets Gets an interface pointer to a zero-based collection of all of the applet objects in an HTML document.
bgColor Deprecated. Sets or retrieves a value that indicates the background color behind the object.
body Gets an interface pointer to the document body object.
charset Sets or retrieves the character set used to encode the object.
clear Not currently supported.
close Closes an output stream and forces the sent data to display.
cookie Sets or gets the string value of a cookie.
createElement Creates an instance of the element for the specified tag.
createStyleSheet Creates a style sheet for the document.
defaultCharset Gets the default character set from the current regional language settings.
designMode Sets or gets a value that indicates whether the document can be edited.
domain Sets or gets the security domain of the document.
elementFromPoint Returns the element for the specified x coordinate and the specified y coordinate.
embeds Gets an interface pointer to a zero-based collection of all of the embed objects in an HTML document.
execCommand Executes a command on the current document, current selection, or the given range.
execCommandShowHelp Displays help information for the given command identifier.
expando Sets or retrieves a value indicating whether arbitrary variables can be created within the object.
fgColor Sets or gets the foreground (text) color of the document.
fileCreatedDate Retrieves the date the file was created.
fileModifiedDate Retrieves the date the file was last modified.
fileSize Retrieves the file size.
fileUpdatedDate Retrieves the date the file was last updated.
forms Gets an interface pointer to a zero-based collection of all the form objects in an HTML document.
frames Gets an interface pointer to a zero-based collection of all of the frame objects in an HTML document, if the document contains the frameSet object. Gets an interface pointer to a zero-based collection of all of the iframe objects in the document, if the document contains the body object.
images Gets a pointer to the IHTMLElementCollection interface of the zero-based collection of all of the images in an HTML document. The images are in the same order as they appear in the document.
lastModified Gets the date that the page was last modified, if the page supplies one.
linkColor Sets or gets the color of the document links.
links Gets an interface pointer to a zero-based collection of all of the link objects and the area objects in an HTML document.
location Retrieves an interface pointer to a location object.
mimeType Retrieves the MIME type for the file.
nameProp Gets the title of the document file.
onafterupdate Sets or retrieves a pointer to the event handler function associated with the onafterupdate event.
onbeforeupdate Sets or retrieves a pointer to the event handler function associated with the onbeforeupdate event.
onclick Sets or retrieves a pointer to the event handler function associated with the onclick event.
ondblclick Sets or retrieves a pointer to the event handler function associated with the ondblclick event.
ondragstart Sets or retrieves a pointer to the event handler function associated with the ondragstart event.
onerrorupdate Sets or retrieves a pointer to the event handler function associated with the onerrorupdate event.
onhelp Sets or retrieves a pointer to the event handler function associated with the onhelp event.
onkeydown Sets or retrieves a pointer to the event handler function associated with the onkeydown event.
onkeypress Sets or retrieves a pointer to the event handler function associated with the onkeypress event.
onkeyup Sets or retrieves a pointer to the event handler function associated with the onkeyup event.
onmousedown Sets or retrieves a pointer to the event handler function associated with the onmousedown event.
onmousemove Sets or retrieves a pointer to the event handler function associated with the onmousemove event.
onmouseout Sets or retrieves a pointer to the event handler function associated with the onmouseout event.
onmouseover Sets or retrieves a pointer to the event handler function associated with the onmouseover event.
onmouseup Sets or retrieves a pointer to the event handler function associated with the onmouseup event.
onreadystatechange Sets or retrieves a pointer to the event handler function associated with the onreadystatechange event.
onrowenter Sets or retrieves a pointer to the event handler function associated with the onrowenter event.
onrowexit Sets or retrieves a pointer to the event handler function associated with the onrowexit event.
onselectstart Sets or retrieves a pointer to the event handler function associated with the onselectstart event.
open Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the IHTMLDocument2::write method and the IHTMLDocument2::writeln method.
parentWindow Gets a reference to the container object of the window.
plugins Gets an interface pointer to a zero-based collection of all of the embed objects in an HTML document.
protocol Sets or retrieves the protocol portion of a URL.
queryCommandEnabled Returns a Boolean value that indicates whether a specified command can be successfully executed using IHTMLDocument2::execCommand, given the current state of the document.
queryCommandIndeterm Returns a Boolean value that indicates whether the specified command is in the indeterminate state.
queryCommandState Returns a Boolean value that indicates the current state of the command.
queryCommandSupported Returns a Boolean value that indicates whether the current command is supported on the current range.
queryCommandText Retrieves the string associated with a command.
queryCommandValue Returns the current value of the document, range, or current selection for the given command.
readyState Retrieves a value that indicates the current state of the object.
referrer Gets the URL of the location that referred the user to the current page.
scripts Gets an interface pointer to a zero-based collection of all of the script objects in an HTML document.
security Not implemented.
selection Gets an interface pointer to an object representing the active selection. The active selection can be an insertion point, a highlighted block of text, or another element in the document that the user or a script can carry out an action on.
styleSheets Gets an interface pointer to a zero-based collection of the style sheet objects exposed from the document object. Each style sheet object represents an individual style sheet that is defined for the document.
title Sets or gets the title of the document.
toString Retrieves a string representation of the object.
URL Sets or gets the URL for the current document.
vlinkColor Sets or gets the color of the links that the user has visited.
write Writes one or more HTML expressions to a document in the specified window.
writeln Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window.

Remarks

Typically, every window object has a corresponding document object that you can get by calling the QueryInterface method with the IID_IHTMLDocument or IID_IHTMLDocument2 interface identifiers. Windows that contain HTML documents always have valid document objects; windows that contain documents in other formats might not have valid document objects.

In general, before you attempt to get the document object for a window that is not the current window, make sure that the source file associated with that window is an HTML document file or a file that can be represented as an HTML document, for example, a text file.

Interface Information

Stock Implementation mshtml.dll
Custom implementation No
Inherits from IDispatch
Header and IDL files Mshtml.h, Mshtml.idl
Minimum availability Internet Explorer 4.0
Minimum operating systems Windows 95, Windows NT 4.0, Windows CE 2.12

http://msdn2.microsoft.com/en-us/library/aa752574(VS.85).aspx

//可以枚举所有的网页链接,然后循环取出即可。
//下面是代码:
//已经调试通过,注意:要在uses里引用mshtml单元。
//效果图见下图:
var
doc: IHTMLDocument2;
all: IHTMLElementCollection;
len, i: integer;
item: OleVariant;
begin
doc := WebBrowser1.Document as IHTMLDocument2;
all := doc.links;
len := all.length;
for i := 0 to len-1 do
begin
item := all.item(i, varempty);
if ListBox.IndexOf(item.href) = -1 then
begin
ListBox1.Items.Append(item.href);
end;
end;
end;

分享到:
评论

相关推荐

    WebBrowser中JS和C++代码互相调用

    2. DispIDs:每个成员方法或属性都有一个唯一的DispID,JS通过这个ID来调用对应的函数。你可以使用Atl DispIdHelper宏或IDispatchImpl类来自动管理这些ID。 3. JScript marshaling:由于JavaScript和C++的类型系统...

    MFC对话框里利用CHtmlView加载界面(二)————MFC调用JaveScript - CSDN博客1

    过CHtmlView调用JavaScript的方法主要涉及ActiveX控件IWebBrowser2的使用,这是Microsoft提供的一个用于在Windows应用程序中嵌入Web浏览器功能的接口。本文将深入探讨如何在MFC对话框中利用CHtmlView加载HTML界面,...

    IE控件一些高级使用方法

    此外,还可以通过设置`IWebBrowser2`的`put_Left`、`put_Top`、`put_Width`、`put_Height`属性来控制其位置和尺寸。 七、多线程使用 在多线程环境中使用IE控件时,需要注意线程同步问题。因为大部分IE控件操作都是...

    cocos-win32下实现WebView网页内嵌

    为了实现JavaScript与C++之间的交互,可以使用`DWebBrowserEvents2`的`DocumentComplete`事件,当网页加载完成后,可以获取到`IHTMLDocument2`接口,然后注册事件处理函数,通过`IHTMLDocument2::execScript`执行...

    IWebBrowser2登陆网站(无验证码的)

    通过IHTMLDocument2,我们可以找到对应的输入元素(通常是id或name属性匹配的元素),然后调用其value属性来设置值。例如,可以使用以下代码: ```cpp IHTMLElement* usernameInput = nullptr; // 获取用户名输入框...

    mfc IE 控件(HtmlView封装类)

    5. **对象访问**:通过`Document`或`DocumentObject`属性,可以获取到`IHTMLDocument2`接口,从而访问网页的DOM元素,进行读写操作。 6. **状态查询**:`ReadyState`属性可以用来检查浏览器的准备状态,判断网页...

    inerHTML.zip_ CHtmlView_CHTMLview _visual c

    对于`innerHTML`的等效操作,可以使用`IHtmlDocument2`的`write`方法来修改整个文档的内容,或者使用`IHTMLElement`接口的`innerHTML`属性来修改特定元素的HTML内容。这些操作通常涉及COM编程,需要理解如何创建和...

    MFC的WebBrowser控件 C++与JavaScript之间数据交互传递

    `IDispatch`接口允许我们调用对象的属性和方法,而`IHtmlDocument2`接口提供了对HTML文档的访问,使我们能够获取或设置页面元素的属性。 1. **C++向JavaScript传递数据**: 在C++端,我们可以使用`...

    CWebPage类

    `CHtmlView`提供了许多方法和属性,如`Navigate()`用于加载URL,`Document`属性可以访问到IHTMLDocument2接口,从而与网页DOM进行交互。 3. **JavaScript交互**: `CWebPage` 类的主要功能可能是为了扩展`...

    MFCHtm lHTML和c++底层程序交互

    6. ** C++调用JavaScript**:C++可以通过IHTMLDocument2接口的`execScript`方法来执行JavaScript代码。这样,C++可以改变HTML元素的状态,或者触发特定的JavaScript函数。 7. ** 数据交换**:HTML和C++之间可以交换...

    vc++能够显示网页html

    例如,你可以调用`IHTMLDocument2`接口的方法来与网页内容交互。 此外,CHtmlView还支持事件处理,你可以定义消息映射函数来响应WebBrowser控件的事件,比如网页加载完成、导航错误等。例如,添加`ON_NOTIFY_EX(TTN...

    mfc下支持HTML的CStatic控件

    4. **处理HTML内容**:重写`OnPaint`函数,将HTML文本作为参数传递给IWebBrowser2的`Navigate2`方法,使其加载HTML内容。同时,可能还需要重写`SetWindowText`函数,以便当设置控件文本时自动处理HTML。 5. **处理...

    C++MFC解析HTML。

    2. 在对话框类(例如`CMyDialog`)中,添加`CHtmlView`成员变量: ```cpp CHtmlView m_htmlView; ``` 3. 在`OnInitDialog()`函数中,初始化`CHtmlView`: ```cpp m_htmlView.Create(NULL, L"Shell.Explorer", WS_...

    vc获取网页中输入的密码框中的内容和文本输入框的内容.zip

    在VC++中,可以通过WebBrowser控件的`Document`属性获取到当前加载页面的`IHTMLDocument2`接口,从而访问DOM树,进而获取到网页中的文本输入框(`<input type="text">`)和密码输入框(`<input type="password">`)...

    VC6中使用CHtmlView在对话框控制中显示HTML文件.zip

    例如,你可以使用`ExecuteScript`方法执行JavaScript,或者通过`IHTMLDocument2`接口来操作DOM元素。 通过以上步骤,你可以在VC6的对话框中成功地使用`CHtmlView`控件显示HTML文件。需要注意的是,由于`CHtmlView`...

    CWebPage类和MFC结合调用JS函数的例子

    然后,你可以使用`CWebPage` 的`Document` 属性获取IHTMLDocument2接口,通过这个接口可以访问到HTML文档的DOM树。一旦有了DOM,你就可以找到JavaScript函数并调用了。例如,假设你的`test.htm` 文件中有名为`...

    MFC IE控件使用方式

    例如,`Navigate()`函数用于导航到指定URL,`Stop()`用于停止当前加载的页面,`GoBack()`和`GoForward()`用于前进和后退,`Document()`返回指向`IHTMLDocument2`接口的指针,通过它可以访问HTML文档的元素和属性。...

    enum_select_elements_demo.rar_DEMO

    例如,`IHTMLDocument2`接口提供了访问HTML文档元素的方法,如`getElementsByTagName`, `getElementById`等,这些方法可以帮助实现HTML元素的枚举。 总的来说,这个DEMO项目提供了一个实用的例子,展示了如何在VC++...

    VC webbrowser 一些用法

    可以使用WebBrowser控件的`Document`属性获取当前页面的IHTMLDocument2接口,通过该接口可以访问页面中的元素并修改其值。例如,假设表单有一个id为"username"的输入框,可以这样填写用户名: ```cpp IDispatch* ...

Global site tag (gtag.js) - Google Analytics