Call back from Java script on WM_QUIT

Discussion of current events and participation in intelligent conversation with other CEF users.

Call back from Java script on WM_QUIT

Postby prasannamavinakuli » Thu Jun 13, 2013 5:13 am

Hello, All.

We need to invoke a java script method on getting the WM_QUIT (cleanup in java script) and only on getting the return we should proceed. We are able to call that java script function on WM_QUIT. but not able to wait. Can you please share some right example to proceed on this?

Thank you very much in advance
Prasanna.
prasannamavinakuli
Newbie
 
Posts: 6
Joined: Thu Jun 13, 2013 4:03 am

Re: Call back from Java script on WM_QUIT

Postby magreenblatt » Thu Jun 13, 2013 9:44 pm

This is what onbeforeunload is for (CEF3 1453 branch). See the DoClose() documentation and cefclient sample application.
magreenblatt
Site Admin
 
Posts: 8036
Joined: Fri May 29, 2009 6:57 pm

Re: Call back from Java script on WM_QUIT

Postby prasannamavinakuli » Fri Jun 14, 2013 1:47 am

Thank you very much for the reply - We have seen the below implementation.
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();

if (m_BrowserId == browser->GetIdentifier()) {

browser->GetMainFrame()->ExecuteJavaScript(
"alert('You pressed the space bar! close is called!!!');", "", 0);
// Since the main window contains the browser window, we need to close
// the parent window instead of the browser window.
CloseMainWindow();

// Return true here so that we can skip closing the browser window
// in this pass. (It will be destroyed due to the call to close
// the parent above.)
return true;
}

But we never got the alert on closing the WM_QUIT. Neither we could not hit the debug point when we enabled. But if I understand your message right, if we invoke a java script from this function it should wait till that java script completes the execution right? Are we missing anything here?

Thanks again and will appreciate your help on this
Prasanna.
prasannamavinakuli
Newbie
 
Posts: 6
Joined: Thu Jun 13, 2013 4:03 am

Re: Call back from Java script on WM_QUIT

Postby magreenblatt » Fri Jun 14, 2013 7:54 am

You need special handling on WM_CLOSE in your application. See WM_CLOSE usage in cefclient_win.cc.
magreenblatt
Site Admin
 
Posts: 8036
Joined: Fri May 29, 2009 6:57 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

Fatal: Not able to open ./cache/data_global.php