The first chapter describes how to open the site, this chapter introduce the use IHTMLDocument3 complete the login blog garden, following is the code:
- SHDocVw.InternetExplorer oBrowser = new SHDocVw.InternetExplorer();
- ;
- object objTargetFrameName = "_self";
- object objPostData = "";
- object objHeaders = "";
- oBrowser.Visible = true;
- oBrowser.Navigate("https://passport.cnblogs.com/user/signin", ref objFlags, ref objTargetFrameName, ref objPostData, ref objHeaders);
- while (true)
- {
- Thread.Sleep();
- if (oBrowser.ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
- break;
- }
- IHTMLDocument3 doc3 = (IHTMLDocument3)oBrowser.Document;
- IHTMLInputElement txtUserName = (IHTMLInputElement)doc3.getElementById("input1");
- txtUserName . value = "your username" ;
- IHTMLInputElement txtPassWord = (IHTMLInputElement)doc3.getElementById("input2");
- txtPassword . value = "your password" ;
- doc3.getElementById("signin").click();
Using the above code successfully logged on to a garden blog, tidy up the following IHTMLDocument3 and related methods and properties:
IHTMLDocument3 way | Explanation |
attachEvent | IE11 from the start, using the addEventListener . The specified function is bound to an event, so that whenever an event is triggered on an object, the function is called. |
createDocumentFragment | Create a new document and returns a pointer to a pointer to the newly created document. |
createTextNode | Create a text string from the specified value. |
detachEvent | Unbind the specified functions from the event, so that the function stop receiving notifications when an event is triggered. |
getElementById | Returns with the specified value id reference to the first object attribute. |
getElementsByName | The name acquired object set value of the attribute. |
getElementsByTagName | Element name based on the specified set of search objects. |
recalc | This element is obsolete and no longer used. Recalculates all the dynamic properties of the current document. |
releaseCapture | Remove the mouse capture from the document in the current object. |
IHTMLDocument3 properties and events | Explanation |
baseUrl | |
to you | Sets or retrieves a value indicating the reading order of the object. |
documentElement | Gets a reference to the document root. |
enableDownload | Set Enable download |
inheritStyleSheets | Yet Description |
onbeforeeditfocus | Before setting the focus |
oncellchange | When the source data changes |
OnContextMenu | When you press the right mouse button menu or via the keyboard trigger a page menu |
onpropertychange | When changing the property |
onrowsdelete | The current data record is deleted |
onrowsinserted | When the current data source you want to insert the new data |
uniqueID | Automatically generated unique identifier of the search target. |
onstop | Stop or leave |
OnDataSetChanged | When the source data changes |
ondatasetcomplete | When the data reception is completed |
OnDataAvailable | When all valid data has been read data source |
This chapter describes the IHTMLDocument3, and log in using IHTMLDocument3 completed, the next chapter IHTMLDocument2 and usage.