Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Sat, 12 Apr 2008 07:45:46 -0700 (PDT),    group: microsoft.public.inetsdk.programming.webbrowser_ctl        back       


How can I know when the URL I specified to Navigate method get loaded?   
Hi, everyone.

I don't know whether this is a stupid question, but I really hope that
you can help me out of it:

I ask the control to navigate with a url "http://foo.bar", then I want
to get the notification when it gets loaded (say, in
NavigateComplete2()). I think up several possible approaches, but I
think they may be all problematic:

Approach (1) Since the input URL of NavigateComplete2 may have been
modified (by server side redirection, etc.), I cannot test whether
this URL equals to "http://foo.bar".

Approach (2) After I invoke Navigate(), I just treat the NEXT
NavigationComplete2 on the top-level frame to be the "http://foo.bar".
However, I think this may be wrong in some rare too, here is an
example:

Invoke Navigate() with "http://not.foo.bar" --> Invoke Navigate() with
"http://foo.bar" --> OnNavigateComplete2( "http://not.foo.bar" ) -->
OnNavigateComplete2( "http://foo.bar" )

Approach (3) Instead of invoking Navigate() to navigate, I think maybe
I can use ITravelLogStg::CreateEntry() with "http://foo.bar", and get
a travel entry FooBarEntry, and then use
ITravelLogStg::TravelTo(FooBarEntry). In OnNavigateComplete2(), I
simply test whehter the current entry is FooBarEntry to know whether
the url has been loaded.

However, when the control just starts up and has no travel entry at
all, invoking ITravelLogStg::CreateEntry() will get an exception in
ieframe.dll !! As a result, before the first travel entry is set up (I
believe it is set up just before the NavigateComplete2 event), I
cannot use this approach.

So, I still cannot conquar the example I mentioned in Approach 2....


Anyone can help me out of this? Thanks very much in advance! My boss
is pushing me....
date: Sat, 12 Apr 2008 07:45:46 -0700 (PDT)   author:   yuzhu.shen

Re: How can I know when the URL I specified to Navigate method get loaded?   
"yuzhu.shen"  wrote in message
news:752b278b-537c-4d42-8921-6e982d72276b@k10g2000prm.googlegroups.com
> I ask the control to navigate with a url "http://foo.bar", then I want
> to get the notification when it gets loaded (say, in
> NavigateComplete2()).

If you want to know when the page is fully loaded, wait for 
DocumentComplete event.

> Approach (1) Since the input URL of NavigateComplete2 may have been
> modified (by server side redirection, etc.), I cannot test whether
> this URL equals to "http://foo.bar".

The first parameter of NavigateComplete2 (and DocumentComplete) is the 
IWebBrowser2 pointer of the browser firing the event. Just check that 
it's the same one you've navigated in the first place.

> Approach (2) After I invoke Navigate(), I just treat the NEXT
> NavigationComplete2 on the top-level frame to be the "http://foo.bar".
> However, I think this may be wrong in some rare too, here is an
> example:
>
> Invoke Navigate() with "http://not.foo.bar" --> Invoke Navigate() with
> "http://foo.bar" --> OnNavigateComplete2( "http://not.foo.bar" ) -->
> OnNavigateComplete2( "http://foo.bar" )

If you call Navigate again on the same browser, any previous navigation 
still in progress will be aborted, and you won't get NavigateComplete2 
event for it.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sat, 12 Apr 2008 11:01:04 -0400   author:   Igor Tandetnik

Re: How can I know when the URL I specified to Navigate method get loaded?   
Thanks. :) You are great!

By the way, Igor, would you please give me some pointers to learn this
control better? I think the document in MSDN may not be sufficient.

For example, I cannot know the fact that you pointed out from the
document of MSDN : If you call Navigate again on the same browser, any
previous navigation still in progress will be aborted, and you won't
get NavigateComplete2 event for it.

Thanks again!
date: Sat, 12 Apr 2008 08:19:12 -0700 (PDT)   author:   yuzhu.shen

Re: How can I know when the URL I specified to Navigate method get loaded?   
"yuzhu.shen"  wrote in message
news:ffbac7ad-806d-405c-a40f-ebd5fda51ce1@k1g2000prb.googlegroups.com
> By the way, Igor, would you please give me some pointers to learn this
> control better? I think the document in MSDN may not be sufficient.

Programming is an experimental science.

> For example, I cannot know the fact that you pointed out from the
> document of MSDN : If you call Navigate again on the same browser, any
> previous navigation still in progress will be aborted, and you won't
> get NavigateComplete2 event for it.

You could have tried it and seen for yourself.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sat, 12 Apr 2008 15:15:22 -0400   author:   Igor Tandetnik

Re: How can I know when the URL I specified to Navigate method get loaded?   
> > Approach (2) After I invoke Navigate(), I just treat the NEXT
> > NavigationComplete2 on the top-level frame to be the "http://foo.bar".
> > However, I think this may be wrong in some rare too, here is an
> > example:
>
> > Invoke Navigate() with "http://not.foo.bar" --> Invoke Navigate() with
> > "http://foo.bar" --> OnNavigateComplete2( "http://not.foo.bar" ) -->
> > OnNavigateComplete2( "http://foo.bar" )
>
> If you call Navigate again on the same browser, any previous navigation
> still in progress will be aborted, and you won't get NavigateComplete2
> event for it.

Hi, Igor.

I thinked up another example this time ( and tested it ).

============================
Currently in page A --> Invoke Navigate() with "http://foo.bar" -->
Very quickly click a link to "http://not.foo.bar" in page A -->
OnNavigateComplete2("http://not.foo.bar")
=============================

In this case, I still cannot determine by the NEXT
OnNavigateComplete2() that "http://foo.bar" gets loaded.
Or, if the url I navigate is not a HTML page, instead it is an exe
file.

============================
Currently in page A --> Invoke Navigate() with "http://foo.bar/a.exe"
--> (no OnNavigateComplete2() for "http://foo.bar/a.exe") --> Some
time later, user click some link or input some other url to navigate --
> OnNavigateComplete2("http://still.not.foo.bar").
=============================

According to these examples, I think approach (2) is still
problematic: after I invoke Navigate() with "http://foo.bar", I cannot
just treat the NEXT NavigationComplete2 on the top-level frame to be
the "http://foo.bar".

Any guidance would be deeply appreciated!!
date: Sat, 12 Apr 2008 21:06:58 -0700 (PDT)   author:   yuzhu.shen

Re: How can I know when the URL I specified to Navigate method get loaded?   
"yuzhu.shen"  wrote in message 
news:24f4ec88-09d7-4b31-8015-85e268610d4b@w4g2000prd.googlegroups.com...
>> > Approach (2) After I invoke Navigate(), I just treat the NEXT
>> > NavigationComplete2 on the top-level frame to be the "http://foo.bar".
>> > However, I think this may be wrong in some rare too, here is an
>> > example:
>>
>> > Invoke Navigate() with "http://not.foo.bar" --> Invoke Navigate() with
>> > "http://foo.bar" --> OnNavigateComplete2( "http://not.foo.bar" ) -->
>> > OnNavigateComplete2( "http://foo.bar" )
>>
>> If you call Navigate again on the same browser, any previous navigation
>> still in progress will be aborted, and you won't get NavigateComplete2
>> event for it.
>
> Hi, Igor.
>
> I thinked up another example this time ( and tested it ).
>
> ============================
> Currently in page A --> Invoke Navigate() with "http://foo.bar" -->
> Very quickly click a link to "http://not.foo.bar" in page A -->
> OnNavigateComplete2("http://not.foo.bar")
> =============================
>
> In this case, I still cannot determine by the NEXT
> OnNavigateComplete2() that "http://foo.bar" gets loaded.
> Or, if the url I navigate is not a HTML page, instead it is an exe
> file.
>
> ============================
> Currently in page A --> Invoke Navigate() with "http://foo.bar/a.exe"
> --> (no OnNavigateComplete2() for "http://foo.bar/a.exe") --> Some
> time later, user click some link or input some other url to navigate --
>> OnNavigateComplete2("http://still.not.foo.bar").
> =============================
>
> According to these examples, I think approach (2) is still
> problematic: after I invoke Navigate() with "http://foo.bar", I cannot
> just treat the NEXT NavigationComplete2 on the top-level frame to be
> the "http://foo.bar".
>
> Any guidance would be deeply appreciated!!


Perhaps implementing DWebBrowserEvents might help you ??
Leslie.
date: Sun, 13 Apr 2008 17:52:33 +1000   author:   Leslie Milburn

Re: How can I know when the URL I specified to Navigate method get loaded?   
"yuzhu.shen"  wrote in message
news:24f4ec88-09d7-4b31-8015-85e268610d4b@w4g2000prd.googlegroups.com
> I thinked up another example this time ( and tested it ).
>
> ============================
> Currently in page A --> Invoke Navigate() with "http://foo.bar" -->
> Very quickly click a link to "http://not.foo.bar" in page A -->
> OnNavigateComplete2("http://not.foo.bar")
> =============================

Right. That's precisely what I predicted would happen. What again seems 
to be the problem?

> In this case, I still cannot determine by the NEXT
> OnNavigateComplete2() that "http://foo.bar" gets loaded.

But of course. It _never_ gets loaded in your scenario. What else did 
you expect?

What exactly are you trying to achieve?

> Or, if the url I navigate is not a HTML page, instead it is an exe
> file.
>
> ============================
> Currently in page A --> Invoke Navigate() with "http://foo.bar/a.exe"
> --> (no OnNavigateComplete2() for "http://foo.bar/a.exe") --> Some
> time later, user click some link or input some other url to navigate
> -- 
>> OnNavigateComplete2("http://still.not.foo.bar").
>> =============================

I still fail to see the problem with this scenario (or any other you 
have propounded).

> According to these examples, I think approach (2) is still
> problematic: after I invoke Navigate() with "http://foo.bar", I cannot
> just treat the NEXT NavigationComplete2 on the top-level frame to be
> the "http://foo.bar".

I never suggested you should.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sun, 13 Apr 2008 08:51:06 -0400   author:   Igor Tandetnik

Re: How can I know when the URL I specified to Navigate method get loaded?   
Hi, Igor.

Thanks for reply!

I am sorry maybe I didn't state my question clearly.

I want to know how to associate a NavigateComplete2 event (or
something like that) with the original request. Put it in other words,
I use Navigate() to ask the control to navigate to some URL, and I
want to know if it is get loaded (if yes, when it is get loaded).

For example, I Navigate() with "http://foo.bar", then I want to konw
if this "http://foo.bar" really takes effect. (including the case that
the source URL has changed with server redirection).

Case 1: The URL takes effect:
Navigate() with "http://foo.bar"  --> I get a NavigateComplete2() for
"http://foo.bar/", and I know (by some way) that this URL is specified
by me. --> "http://foo.bar" takes effect!

Case 2: The URL takes effect:
Navigate() with "http://foo.bar"   -->  I get a NavigateComplete2()
for "http://redirect.foo.bar", but I know (by some way) that this URL
is redirected from "http://foo.bar". -->  Great! "http://foo.bar"
takes effect!

Case 3: The URL doesn't take effect:
Currently in page A --> Invoke Navigate() with "http://foo.bar" -->
Very quickly click a link to "http://not.foo.bar" in page A --> I get
a NavigateComplete2() for "http://not.foo.bar". By some way, I know
that this "http://not.foo.bar" is not related to my original request.
--> OK, "http://foo.bar" doesn't take effect.


On Apr 13, 8:51 pm, "Igor Tandetnik"  wrote:
> "yuzhu.shen"  wrote in message
>
> news:24f4ec88-09d7-4b31-8015-85e268610d4b@w4g2000prd.googlegroups.com
>
> > I thinked up another example this time ( and tested it ).
>
> > ============================
> > Currently in page A --> Invoke Navigate() with "http://foo.bar" -->
> > Very quickly click a link to "http://not.foo.bar" in page A -->
> > OnNavigateComplete2("http://not.foo.bar")
> > =============================
>
> Right. That's precisely what I predicted would happen. What again seems
> to be the problem?
>
> > In this case, I still cannot determine by the NEXT
> > OnNavigateComplete2() that "http://foo.bar" gets loaded.
>
> But of course. It _never_ gets loaded in your scenario. What else did
> you expect?
>
> What exactly are you trying to achieve?
>
> > Or, if the url I navigate is not a HTML page, instead it is an exe
> > file.
>
> > ============================
> > Currently in page A --> Invoke Navigate() with "http://foo.bar/a.exe"
> > --> (no OnNavigateComplete2() for "http://foo.bar/a.exe") --> Some
> > time later, user click some link or input some other url to navigate
> > --
> >> OnNavigateComplete2("http://still.not.foo.bar").
> >> =============================
>
> I still fail to see the problem with this scenario (or any other you
> have propounded).
>
> > According to these examples, I think approach (2) is still
> > problematic: after I invoke Navigate() with "http://foo.bar", I cannot
> > just treat the NEXT NavigationComplete2 on the top-level frame to be
> > the "http://foo.bar".
>
> I never suggested you should.
> --
> With best wishes,
>     Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
date: Mon, 14 Apr 2008 18:48:27 -0700 (PDT)   author:   yuzhu.shen

Re: How can I know when the URL I specified to Navigate method get loaded?   
Thanks for your reply. :)

Sorry that I may no ask the question clearly. I am using
DWebBrowserEvents2.

On Apr 13, 3:52 pm, "Leslie Milburn"  wrote:
> "yuzhu.shen"  wrote in message
>
> news:24f4ec88-09d7-4b31-8015-85e268610d4b@w4g2000prd.googlegroups.com...
>
>
>
> >> > Approach (2) After I invoke Navigate(), I just treat the NEXT
> >> > NavigationComplete2 on the top-level frame to be the "http://foo.bar".
> >> > However, I think this may be wrong in some rare too, here is an
> >> > example:
>
> >> > Invoke Navigate() with "http://not.foo.bar" --> Invoke Navigate() with
> >> > "http://foo.bar" --> OnNavigateComplete2( "http://not.foo.bar" ) -->
> >> > OnNavigateComplete2( "http://foo.bar" )
>
> >> If you call Navigate again on the same browser, any previous navigation
> >> still in progress will be aborted, and you won't get NavigateComplete2
> >> event for it.
>
> > Hi, Igor.
>
> > I thinked up another example this time ( and tested it ).
>
> > ============================
> > Currently in page A --> Invoke Navigate() with "http://foo.bar" -->
> > Very quickly click a link to "http://not.foo.bar" in page A -->
> > OnNavigateComplete2("http://not.foo.bar")
> > =============================
>
> > In this case, I still cannot determine by the NEXT
> > OnNavigateComplete2() that "http://foo.bar" gets loaded.
> > Or, if the url I navigate is not a HTML page, instead it is an exe
> > file.
>
> > ============================
> > Currently in page A --> Invoke Navigate() with "http://foo.bar/a.exe"
> > --> (no OnNavigateComplete2() for "http://foo.bar/a.exe") --> Some
> > time later, user click some link or input some other url to navigate --
> >> OnNavigateComplete2("http://still.not.foo.bar").
> > =============================
>
> > According to these examples, I think approach (2) is still
> > problematic: after I invoke Navigate() with "http://foo.bar", I cannot
> > just treat the NEXT NavigationComplete2 on the top-level frame to be
> > the "http://foo.bar".
>
> > Any guidance would be deeply appreciated!!
>
> Perhaps implementing DWebBrowserEvents might help you ??
> Leslie.
date: Mon, 14 Apr 2008 18:50:51 -0700 (PDT)   author:   yuzhu.shen

Re: How can I know when the URL I specified to Navigate method get loaded?   
"yuzhu.shen"  wrote in message
news:0dd585eb-872f-4d86-b690-dbd21e499cef@p39g2000prm.googlegroups.com
> I want to know how to associate a NavigateComplete2 event (or
> something like that) with the original request. Put it in other words,
> I use Navigate() to ask the control to navigate to some URL, and I
> want to know if it is get loaded (if yes, when it is get loaded).

Watch BeforeNavigate2 event. NavigateComplete2 would correspond to the 
latest BeforeNavigate2.

Right after you call Navigate, you would get BeforeNavigate2 event 
indicating that the navigation has started. If you get NavigateComplete2 
without any intervening BeforeNavigate2, then it's for your request. If 
you get another BeforeNavigate2 instead, it means some other navigation 
has started (e.g. by user clicking on a link) and your request is 
abandoned.

You may also want to watch NavigateError event, in case your request 
fails for some reason without ever reaching NavigateComplete2 state.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Tue, 15 Apr 2008 07:44:28 -0400   author:   Igor Tandetnik

Re: How can I know when the URL I specified to Navigate method get loaded?   
Thanks very much! Igor.

That is really helpful.
date: Thu, 17 Apr 2008 01:06:14 -0700 (PDT)   author:   yuzhu.shen

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us