Some knowledge that needs to be mastered before learning Internet Explorer

xiaoxiao2021-03-06  70

Before learning Internet Explorer programming, you learned that MSHTML, IE implements the mark (TAG) in the HTML language, and encapsulated by the MSHTML.dll. MSHTML is a COM component-based object model whose interface is based on iDispatch. For the introduction of MSHTML, please see

MSDN documentation, Chinese version can refer to the article below.

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 to familiarize with the configuration and functionality of the Object Model References defined in the dynamic HTML introduction and the object model 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 using 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 The Object Model Interface Microsoft (R) Visual C (R) code presentation is on the DRILLER Example Source Code Page and 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 depends on how your application is implemented. Each of the following occasions needs to be obtained in a different way.</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 object using CoCreateInstance. Once an object is created, you can call its QueryInterface method, request IID_IHTMLDocument2. Walkall Example Sample Page The Walkall sample illustrates how it is.</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>Access dynamic HTML section of the ActiveX document 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 IHTMLDocument2 :: all (Translator Note: Original, it seems to be changed to get_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. IHTMLELEMENTCOLLECTION :: Item method provides you with an iDispatch pointer you can call QueryInterface, request IID_IHTMLELEMENT. This will give you an IHTMLEMENT 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 an element-related interface, you can call QueryInterface on the IHTMLELEMENT interface, request the interface related to the required elements. For example, an IMG element provides an IHTMLIMGELEMENT interface to specifically manipulate the IMG element. To see an interface list related to the available elements, view the interface list of interfaces and script objects.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-110453.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="110453" 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.043</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 = 'XRaa_2BZEB39pJmrWoJfg8Eof7Txkww5frs6uspHoPyrGWT8buwfo4Ioo730KDrqKYqEwMUE5TNqTAvZcMLgt5hQ_3D_3D'; 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>