Solved

Capturing refresh event on IE

Posted on 2001-08-20
7
1,736 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 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

22 Experts available now in Live!

Get 1:1 Help Now