Herein translation
http://msdn.microsoft.com/workshop/browser/mshtml/overview/overview.asp
MSDN HOME>
MSDN LIBRARY>
Programming and reusing the browser>
Overviews / tutorials
About MSHTML
All interfaces of the access dynamic HTML (DHTML) object model are based on iDispatch, and is also the basis for the object model used for scripts. Therefore, anyone to manipulate the object model is important to familiarize with the configuration and function of the object model defined in the dynamic HTML introduction and the object model reference included in the MSHTML.
MSHTML Reference Interface and Script Object This section describes how objects are mapped to the interface in the DHTML object model. For example, using this map, you can see the IHTMLDocument2 interface map to the document object. Further research on the interface illustrates how to access objects of objects via GET_ and PUT_ methods. The object's method is mapped to the method of available interfaces, and events can be captured with standards automated connection points.
How to make an object of an object model interface In colbartn, driller, and Walkall examples, these examples are on the COLBTN sample source code page, a DRILLER sample source code page, and a Walkall Example Source code page.
Use the advice to use the interface to obtain the topic related to the document interface
Advice using the interface
Typically, anything that can be done with scripts in documentation can be done by using an interface manipulation object model. Therefore, it is recommended that the developer should use the script design function prototype in an HTML document before writing the code of the object model interface.
The following HTML examples illustrate how to use the script navigation document ALL collection and get the tag name of each element of the document. Equivalent to the Microsoft (R) Visual C (R) of the Object Model Interface You can find on the DRILLER sample source code page and the Walkall Example Source code page.
example
HEAD>
Function loaded ()
{
VAR C = Document.all.length;
Var i;
For (i = 0; i { Spantags.innerhtml = spantags.innerhtml Document.all.Item (i) .tagname " } } Script>
";
span>
Body>
Html>
Get a document interface
To start using an object model interface, you have to get the IHTMLDocument2 interface from the document. Once you have this interface, you can access all the elements in the document. How to get the document interface depends on your application's implementation. The following occasions need to be obtained in different ways.
An instance of integrating a browser control while integrating MSHTML. A Microsoft ActiveX (R) control included from a web page.
Document interface when integrated MSHTML
When you integrate a MSHTML object, create an HTML document object using CoCreateInstance. Once an object is created, you can call its QueryInterface method, request IID_IHTMLDocument2. Walkall Example Source Code Page The Walkall example illustrates the implementation method.
Document interface when integrated browser control
When integrating browser controls, perform the following steps to get a document interface:
Call iWebBrowser2 :: get_document to get the IDispatch interface of the document. (Translator Note: The gethtmlDocument method of the MFC, the DOCUMENT property of the browser control, or the DOM attribute of the DHTMLEDIT control can also be used to obtain the document interface. Get the document interface from the ActiveX control
ActiveX Document Access Dynamics HTML This section explains how to get a document interface from the ActiveX (R) control.
Use document interface
Use document interface
Once you get a document interface, you can use any of the IHTMLDocument2 interface to get or modify the properties of the document. This usually includes some IHTMLELEMENTCOLLECTION interfaces from different elements contained from the document.
A very common collection of objects is all set objects. ALL collection object is obtained by using the IHTMLDocument2 :: all method. This method returns an IHTMLELEMEMENTCOLLECTION interface for all elements of the document. Then you can enumerate the elements using the IHTMLELEMENTCOLLECTION :: Item method. The IHTMLELEMENTCOLLECTION :: Item method provides you with a IDispatch pointer that can be used to call QueryInterface, request IID_IHTMLELEMENT. This will return to you an ihtmlelement interface pointer that you can use to get or set information for individual elements.
Most elements provide an interface to manipulate the particular element. These elements related interface names have IHTMLXXXELEMENT format, where xxxx is the name of the element. To obtain the corresponding interface of the element, you can call QueryInterface on the IHTMLELEMENT interface, request the interface related to the required elements. For example, the IMG element provides an IHTMLIMGELEMENT interface to specifically manipulate the IMG element. If you want to see a list of interfaces related to the available elements, you can view the interface list of interfaces and script objects.
Related topic
MSHTML Editing Function Introduction MSHTML Tag Service Introduction Creating an HTML Resource MSHTML Reference (Translator Recommended) Accelerate a group of skills of DHTML