Learn libcef--together to set the URL for your browser

Source: Internet
Author: User

If you are a beginner, you are likely to have the same problem with me, that is, how to set a URL for CEF browser or change the URL of CEF browser.

For creating a browser, you can easily navigate and then create browser when you pass a URL. For example, navigate to "www.baidu.com". But next, you want to navigate to "www.google.com", what would you do?

Perhaps you will recreate a browser and successfully navigate to "www.google.com". But at this point, you open the Task Manager to look at, you can clearly see that there are two browser running.

So, what I'm going to say is how to SetUrl or Loadrul on the same browser.

Createbrowser:

std::wstring url = L"www.baidu.com";CefBrowserHost::CreateBrowser(info, g_web_browser_client.get(),            CefString(url), browserSettings, NULL);

Next, the first is to get a pointer to the browser, then through the Getmainfram function, and then call Loadurl, to access the URL you want.

std::wstring url2 = "www.google.com"CefRefPtr<CefBrowser> browser = g_web_browser_client->GetBrowser();browser->GetMainFrame()->LoadURL(CefString(url2));  

Getmainframe

publicvirtualGetMainFrame0;

Returns the main (top-level) frame for the browser window.

Loadurl

publicvirtualvoidLoadURLconst0;

Load the specified |url|.

Learn libcef--together to set the URL for your browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.