Solved

Capturing refresh event on IE

Posted on 2001-08-20
7
1,738 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now