Detecting page navigation

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Detecting page navigation

Postby RenderMonkey » Tue Nov 03, 2015 2:57 pm

Hello all,

I am probably missing something simple here but how can detect when an URL is being requested through a navigation, that is for instance a new page request through a click on a link or the loading of the specified startup page.
I am aware of CefRequestHandler::OnBeforeBrowse and CefRenderProcessHandler::OnBeforeNavigation but they don't really help me since they can get called multiple times per loaded page (I thought OnBeforeNavigation would do the trick but it doesnt seem to do what I think it does since it gets triggered multiple times so I guess navigation means something different in this context). I am interested in tracking the startup page and link navigation but not the loaded resources of the pages themselves.

Thanks for the help!
RenderMonkey
Techie
 
Posts: 25
Joined: Wed Oct 07, 2015 10:52 am

Re: Detecting page navigation

Postby amaitland » Tue Nov 03, 2015 6:10 pm

Does your webpage have frames? Most of the functions related to navigation will be called multiple times, once for each frame.

In most cases you need to check `CefFrame::IsMain()` for the primary navigation event.

apidocs3/projects/%28default%29/CefFrame.html#IsMain%28%29

You also need to consider redirects triggering the calls more than once.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Detecting page navigation

Postby RenderMonkey » Thu Nov 05, 2015 11:05 am

Forgot to reply - thanks, that was what I was looking for :)
RenderMonkey
Techie
 
Posts: 25
Joined: Wed Oct 07, 2015 10:52 am

Re: Detecting page navigation

Postby amaitland » Thu Nov 05, 2015 8:35 pm

No problem, glad you sorted it.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 37 guests