Home > Software engineering >  CHtmlView frame more pages to determine whether a page is completely loaded
CHtmlView frame more pages to determine whether a page is completely loaded

Time:02-04

Flexible to the UI changes, I do interface using local web page, the page complete response time to figure out which a specific page loading is completed, and then do some business related operations, so judge a page load to complete is very important, but how much page frame becomes very complex, under the condition of normal frame load success can be judged in accordance with the method of net friend, such as:
https://www.xuebuyuan.com/1182745.html the way mentioned in the article,
when it comes to failure of frame this way of judgment will be failure
See a lot of net friend way of judgment, and basically are flawed, and there is no real find a good way to judge whether the page actually loaded,
In order to study the law of incident response, overloading the most function did not do any interference to track message routing operation, only do the log output, as follows:
 void CMyHtmlView: : NavigateComplete2 (LPDISPATCH pDisp and VARIANT * URL) 
{
PrintNavLog (URL - & gt; BstrVal);//print log

CHtmlView: : NavigateComplete2 (pDisp, URL);
}

test 1:
Local test page contains only a single failure of frame element http://127.0.0.1
 & lt; The iframe ID="test1" name="test1" SRC="http://127.0.0.1" & gt; </iframe> 

The message log response is as follows:
 CMyHtmlView: : BeforeNavigate2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING] 
CMyHtmlView: : OnBeforeNavigate2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING]
CMyHtmlView: : BeforeNavigate2 url: [http://127.0.0.1/] ready state: [READYSTATE_LOADING]
CMyHtmlView: : OnBeforeNavigate2 url: [http://127.0.0.1/] ready state: [READYSTATE_LOADING]
CMyHtmlView: : NavigateComplete2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING]
CMyHtmlView: : OnNavigateComplete2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING]
CMyHtmlView: : NavigateError url: [http://127.0.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnProgressChange url: [-] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : DocumentComplete url: [] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnDocumentComplete url: [] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : NavigateError url: [http://127.0.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : BeforeNavigate2 url: [res://ieframe. DLL/navcancl. Htm# http://127.0.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnBeforeNavigate2 url: [res://ieframe. DLL/navcancl. Htm# http://127.0.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : NavigateComplete2 url: [res://ieframe. DLL/navcancl. Htm# http://127.0.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnNavigateComplete2 url: [res://ieframe. DLL/navcancl. Htm# http://127.0.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnProgressChange url: [-] ready state: [READYSTATE_INTERACTIVE]

The result shows: the will only trigger a DocumentComplete and don't take the url, so not local page test. The complete response of HTML, local page does not have a complete response in
test 2:
Local test page contains only a single failure of frame element http://192.168.0.1
 & lt; The iframe ID="test1" name="test1" SRC="http://192.168.0.1" & gt; </iframe> 

The message log response is as follows:
 CMyHtmlView: : BeforeNavigate2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING] 
CMyHtmlView: : OnBeforeNavigate2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING]
CMyHtmlView: : BeforeNavigate2 url: [http://192.168.0.1/] ready state: [READYSTATE_LOADING]
CMyHtmlView: : OnBeforeNavigate2 url: [http://192.168.0.1/] ready state: [READYSTATE_LOADING]
CMyHtmlView: : NavigateComplete2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING]
CMyHtmlView: : OnNavigateComplete2 url: [D: \ test. HTML] ready state: [READYSTATE_LOADING]
CMyHtmlView: : NavigateError url: [http://192.168.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : NavigateComplete2 url: [http://192.168.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnNavigateComplete2 url: [http://192.168.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnProgressChange url: [-] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : DocumentComplete url: [http://192.168.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : OnDocumentComplete url: [http://192.168.0.1/] ready state: [READYSTATE_INTERACTIVE]
CMyHtmlView: : DocumentComplete url: [D: \ test. HTML] ready state: [READYSTATE_COMPLETE]
CMyHtmlView: : OnDocumentComplete url: [D: \ test. HTML] ready state: [READYSTATE_COMPLETE]

The result shows: the frame and local page will have complete event triggers, but order is frame before the page, it will cause the local page will have been waiting for the frame before trigger, takes longer, then contrast test shows: 1 http://127.0.0.1 is a certain particularity?

test 3
Local page contains a bookmark:
 & lt; A href="https://bbs.csdn.net/topics/#bottom" onclick="console. The log (' # bottom)" & gt; Test # & lt;/a> 

The message log response is as follows:
 CMyHtmlView: : BeforeNavigate2 url: [file:///D:/test.html#bottom] ready state: [READYSTATE_COMPLETE] 
CMyHtmlView: : OnBeforeNavigate2 url: [file:///D:/test.html#bottom] ready state: [READYSTATE_COMPLETE]
CMyHtmlView: : NavigateComplete2 url: [file:///D:/test.html#bottom] ready state: [READYSTATE_COMPLETE]
CMyHtmlView: : OnNavigateComplete2 url: [file:///D:/test.html#bottom] ready state: [READYSTATE_COMPLETE]
CMyHtmlView: : DocumentComplete url: [file:///D:/test.html#bottom] ready state: [READYSTATE_COMPLETE]
nullnullnullnullnullnullnullnullnull
  • Related