About MSHTML

zhaozj2021-02-08  244

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

page title </ title></p> <p></ HEAD></p> <p><Script language = "javascript"></p> <p>Function loaded ()</p> <p>{</p> <p>VAR C = Document.all.length;</p> <p>Var i;</p> <p>For (i = 0; i <c; i )</p> <p>{</p> <p>Spantags.innerhtml = spantags.innerhtml Document.all.Item (i) .tagname "<br>";</p> <p>}</p> <p>}</p> <p></ Script></p> <p><Body οnlοad = "loaded ()"></p> <p><Span id = "spantags"> </ span></p> <p></ Body></p> <p></ Html></p> <p>Get a document interface</p> <p>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.</p> <p>An instance of integrating a browser control while integrating MSHTML. A Microsoft ActiveX (R) control included from a web page.</p> <p>Document interface when integrated MSHTML</p> <p>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.</p> <p>Document interface when integrated browser control</p> <p>When integrating browser controls, perform the following steps to get a document interface:</p> <p>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</p> <p>ActiveX Document Access Dynamics HTML This section explains how to get a document interface from the ActiveX (R) control.</p> <p>Use document interface</p> <p>Use document interface</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>Related topic</p> <p>MSHTML Editing Function Introduction MSHTML Tag Service Introduction Creating an HTML Resource MSHTML Reference (Translator Recommended) Accelerate a group of skills of DHTML</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-1848.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="1848" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.046</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'X4d_2Ftf5NMTl3AWq1we8yTmBE2mj241ygn1SJE461Y5Z9lNio3qFBCQNnWj6V6GTpIhK_2B_2FspBa00z7I5z'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>