Solved

Capturing refresh event on IE

Posted on 2001-08-20
7
1,744 Views
Last Modified: 2013-12-03
Am trying to capture the Refresh event of a html page.
I am using an activeX component that implement few inerfaces and sink dwebbrowserevents as well but didn't find a way I could capture the 'refresh' event (the browser won't send a 'BeforeNavigate' nor 'Document/DownloadComplete').
The best I could come to (so far) is capturing the onbeforeunload (of the IHTMLWindow2 obj) of the document and distinguish between a case where the browser had a 'BeforeNavigate' event just  before the onbeforeunload event initiated. Still it's kinda screwy way...
Looking 4 help!
0
Comment
Question by:GuyK
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6405576
have you tried dwebbrowserevents2 ?
0
 

Author Comment

by:GuyK
ID: 6405597
Am trying to capture the Refresh event of a html page.
I am using an activeX component that implement few inerfaces and sink DWEBBROWSEREVENTS2 as well but
didn't find a way I could capture the 'refresh' event (the browser won't send a 'BeforeNavigate/2' nor
'Document/DownloadComplete/2').
The best I could come to (so far) is capturing the onbeforeunload (of the IHTMLWindow2 obj) of the document
and distinguish between a case where the browser had a 'BeforeNavigate' event just  before the onbeforeunload
event initiated. Still it's kinda screwy way...
Looking 4 help!

(see corrections...)
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6406008
strange that you are not seeing a BeforeNavigateEvent - I have not trouble seeing that event at all

How have you set up the receiving of events? code sample could be useful here
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:GuyK
ID: 6406075
Hi Shaun,
Strange your browser fires a 'BeforeNavigate' event because mine doesn't.
Let me add more details:
I'm using IE5 on OS Windows 2000.

If it helps, here's the code:

******* CWBMyHost.h **********
class CWBMyHost:
public.......
....
....
public IDispEventImpl<0, CWBMyHost, &__uuidof(SHDocVw::DWebBrowserEvents2), &LIBID_SHDocVw, 1, 0>,
public...

.
.
.
.
BEGIN_SINK_MAP(CWBMyHost)
   SINK_ENTRY_EX(0, (__uuidof(SHDocVw::DWebBrowserEvents2)), DISPID_DOCUMENTCOMPLETE, NavigateComplete)
   SINK_ENTRY_EX(0, (__uuidof(SHDocVw::DWebBrowserEvents2)), DISPID_BEFORENAVIGATE2, BeforeNavigate)
END_SINK_MAP()
.
.
.
.
STDMETHOD(NavigateComplete)(IDispatch* pDisp, VARIANT* URL);
STDMETHOD(BeforeNavigate)(IDispatch *pDisp,
               VARIANT *URL,
               VARIANT *Flags,
               VARIANT *TargetFrameName,
               VARIANT *PostData,
               VARIANT *Headers,
               VARIANT_BOOL *Cancel);
.
.
.
.
};

******* CWBMyHost.cpp **********

.
.
.
STDMETHODIMP CWBMyHost::NavigateComplete(IDispatch* pDisp, VARIANT* URL)
{
...
}

STDMETHODIMP CWBMyHost::BeforeNavigate(IDispatch *pDisp,
    VARIANT *URL,
    VARIANT *Flags,
    VARIANT *TargetFrameName,
    VARIANT *PostData,
    VARIANT *Headers,
    VARIANT_BOOL *Cancel
)
{
...
}

.
.
.

But I don't think the code is problematic (in this manner) because I do get these events when I navigate (through links or through the back/forward buttons)


0
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 119 total points
ID: 6406310
oops you right - my refresh button - was an actual wrapped Navigate() with the last URL (strange what you do late at night and can't remeber why) - you do get a downloadbegin/complete events which you can use - eg if you get a download complete without a BeforeNavigate then it must be a refresh
0
 

Author Comment

by:GuyK
ID: 6409026
Sometimes the answer is right under your nose but you need someone (usually from the outside) to show it to you.
This is just what you did. Thanks
p.s.
I know it looks obvious but still - thanks a lot
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6409039
glad to help :)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question