Load an url on an existing browser immediatly after creation

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Load an url on an existing browser immediatly after creation

Postby Dublanc » Mon Dec 10, 2012 7:58 am

Is there any way to do that ?

{
...
CefBrowser::CreateBrowser(info, static_cast< CefRefPtr<CefClient> >(this), "about:blank", browserSettings);
GetBrowser()->GetMainFrame()->LoadURL("http://www.google.fr"):
...
}

Or find a way to wait until "about:blank" is created, CreateBrowserSync doesn't work

Thanks
Dublanc
Mentor
 
Posts: 53
Joined: Thu Mar 29, 2012 4:22 am

Re: Load an url on an existing browser immediatly after crea

Postby magreenblatt » Mon Dec 10, 2012 9:46 am

Why not pass the URL to CreateBrowser instead of "about:blank"?
magreenblatt
Site Admin
 
Posts: 10462
Joined: Fri May 29, 2009 6:57 pm

Re: Load an url on an existing browser immediatly after crea

Postby Dublanc » Tue Dec 11, 2012 5:09 am

The code above is just a summary, it's just when i create a browser i can't know immediatly what url will be link with it. So i need to wait until "about:blank" is created. Is there any way/flag to know when the brower is ready to accept a new url ?
Dublanc
Mentor
 
Posts: 53
Joined: Thu Mar 29, 2012 4:22 am

Re: Load an url on an existing browser immediatly after crea

Postby magreenblatt » Tue Dec 11, 2012 5:14 am

You could call LoadURL() from CefLifeSpanHandler::OnAfterCreated().
magreenblatt
Site Admin
 
Posts: 10462
Joined: Fri May 29, 2009 6:57 pm

Re: Load an url on an existing browser immediatly after crea

Postby Dublanc » Tue Dec 11, 2012 7:29 am

Works fine !

Thanks !
Dublanc
Mentor
 
Posts: 53
Joined: Thu Mar 29, 2012 4:22 am

Re: Load an url on an existing browser immediatly after crea

Postby mmarczell » Fri Jul 03, 2020 7:37 am

The above solution (admittedly 8 years old) doesn't seem to work in the version we're using (v83).
This is the sequence of events I'm observing:
1. I call CreateBrowser from the main thread with URL A
2. I call LoadURL from OnAfterCreated with URL B
3. OnBeforeBrowse is called with URL B
4. OnBeforeBrowse is called with URL A
5. CEF appears showing URL A

My usecase would be: (on a Mac)
- The app is not running
- The user drags a file onto the app
- NSApplication and the app delegate is created. This calls CreateBrowser with URL A (default starting screen for the app)
- application:openFile: is called on the app delegate. In here I save URL B (that would show the content of the opened file) somewhere to be opened later
- OnAfterCreated would be the opportunity to override what URL we show on start.
mmarczell
Newbie
 
Posts: 5
Joined: Wed Feb 26, 2020 6:06 am

Re: Load an url on an existing browser immediatly after crea

Postby magreenblatt » Fri Jul 03, 2020 10:49 am

If you wish to navigate from OnAfterCreated you should create the browser with an empty URL parameter.
magreenblatt
Site Admin
 
Posts: 10462
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 21 guests