To successfully walk the HTML Scripting Object Model that the parser exposes after loading the specified document, the host application must wait until MSHTML has finished loading the document. To track MSHTML's READYSTATE, the host implements a simple COM object that exposes IPropertyNotifySink. The host application connects to MSHTML using the standard connection point interfaces. As MSHTML loads the document it's readiness state changes. To notify the host of these changes, it executes IPropertyNotifySink.OnChanged passing along the DISPID of the property that has changed (DISPID_READYSTATE). The host uses MSHTML's automation interface obtained at creation time to retrieve the current value of this property. When the value equals READYSTATE_COMPLETE, MSHTML has finished loading the document.
If the loaded document is an HTML page which contains scripts, Java Applets and/or ActiveX controls, and those scripts are coded for immediate execution, MSHTML will
execute them by default. To disable this feature, the host must implement two additional interfaces: IOleClientSite and IDispatch. At initialization time, after MSHTML is instantiated, the host should query MSHTML for its IOleObject interface, pass MSHTML a reference to its IOleClientSite interface, query MSHTML for its IOleControl
interface, and call OnAmbientPropertyChange(DISPID_AMBIENT_DLCONTROL). MSHTML will in turn query the host's IOleClientSite interface for IDispatch and then request the value of this property from the host. This is the hosts opportunity to control MSHTML, disabling the execution of scripts, etc.
If the loaded document is an HTML page which contains scripts, Java Applets and/or ActiveX controls, and those scripts are coded for immediate execution, MSHTML will
execute them by default. To disable this feature, the host must implement two additional interfaces: IOleClientSite and IDispatch. At initialization time, after MSHTML is instantiated, the host should query MSHTML for its IOleObject interface, pass MSHTML a reference to its IOleClientSite interface, query MSHTML for its IOleControl
interface, and call OnAmbientPropertyChange(DISPID_AMBIENT_DLCONTROL). MSHTML will in turn query the host's IOleClientSite interface for IDispatch and then request the value of this property from the host. This is the hosts opportunity to control MSHTML, disabling the execution of scripts, etc.
本文介绍了一种通过跟踪MSHTML的READYSTATE来确保文档加载完成的方法。主机应用通过实现IPropertyNotifySink接口并连接到MSHTML的标准连接点接口来监测文档加载状态。当文档加载完成并达到READYSTATE_COMPLETE状态时,可以通过禁用脚本执行等功能来进一步控制MSHTML的行为。
5964

被折叠的 条评论
为什么被折叠?



