Re: Reload detection
- From: Jan Ostedt <ostedt@xxxxxxxxxx>
- Date: Fri, 15 Jun 2007 15:53:36 +0200
Thank you very much for your answer! The proposed method is a good way
to identify a refresh, but if I want to cancel the operation I think it's too late
to detect it in DownloadBegin. Please correct me if I'm wrong.
Right now I'm considering trying to implement an Asynchronous Pluggable
Protocol handler to solve the problem. Could an APP handler be used to
detect and cancel a refresh request from the web browser control? Igor, is
that feasible?
Regards
Jan
Jan Ostedt
www.learnware.se
do you think about that
On Thu, 14 Jun 2007 06:28:23 -0700, mh <mehr13@xxxxxxxxxxx> wrote:
On Jun 12, 10:40 am, Jan Ostedt <ost...@xxxxxxxxxx> wrote:
Hello!
I'm using MFC (CHtmlView). I would like to trap a page refresh at an early stage to be able to
cancel it.
If the page refresh is caused by a meta tag I'm able to trap the event in BeforeNavigate2, but
if the page refresh is caused by javascript (location.reload()) I'm not able to trap the event at all.
How can that be done?
I have implemented IOleCommandTarget in order to catch OLECMDID_PREREFRESH. I succeeded
to catch the call, but it seems to take place very late in the reload process (in spite of its name) , so that
didn't work. I've worked on this for a while so I would really appreciate if someone could help me out.
Thanks in advance!
Best Regards
Jan
1) Add three variables:
// counter to monitor number of requests to BeforeNavigate2 vs number
of requests to DownloadBegin.
int m_nPageCounter;
// counter to monitor number of DownloadBegin and DownloadEnd calls.
int m_nObjCounter;
// variable to tell us whether a refresh request has started.
BOOL m_bIsRefresh;
2) In BeforeNavigate2 add:
m_nPageCounter++;
3) In DocumentComplete add:
m_nPageCounter--;
if( (m_bIsRefresh) && (m_nPageCounter == 0) && (m_nObjCounter == 0) )
{
//Refresh end
m_bIsRefresh = FALSE;
}
4) In DownloadBegin add:
m_nObjCounter++;
//Refresh started
if(m_nPageCounter == 0)
{
m_bIsRefresh = TRUE;
}
5) In DownloadComplete add
m_nObjCounter--;
//Refresh Ended
if( (m_bIsRefresh) && (m_nPageCounter == 0) && (m_nObjCounter == 0) )
{
m_bIsRefresh = FALSE;
}
Hope this helps
MH
.
- Follow-Ups:
- Re: Reload detection
- From: Igor Tandetnik
- Re: Reload detection
- References:
- Reload detection
- From: Jan Ostedt
- Re: Reload detection
- From: mh
- Reload detection
- Prev by Date: When does the DocumentComplete event get fired?
- Next by Date: Re: When does the DocumentComplete event get fired?
- Previous by thread: Re: Reload detection
- Next by thread: Re: Reload detection
- Index(es):
Relevant Pages
|
|