How to get JS function result value

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.

How to get JS function result value

Postby carlosb007 » Thu Apr 01, 2010 3:29 am

In order to call a javascript function and get the result value back I either use 'alert' and get the response through handle_jsalert or use a registered V8 extension function. In any case there's the need to call execute_java_script and then cef_do_message_loop_work to have the handle callback being executed, but cef_do_message_loop_work causes the application message loop to be processed too which is causing me some unwanted behaviour.

Any tip on how to execute a JS function, get the result value back and don't have the application message loop being processed in the meantime? I may be missing some obvious solution... :?
carlosb007
Newbie
 
Posts: 9
Joined: Thu Apr 01, 2010 2:50 am

Re: How to get JS function result value

Postby magreenblatt » Thu Apr 01, 2010 8:58 am

Hi Carlos,

JavaScript will not be executed unless the message loop runs due to the logical reason that the JavaScript needs to be run :-). Perhaps if you tell us the end goal of what you're trying to achieve we can suggest a different approach.

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to get JS function result value

Postby carlosb007 » Mon Apr 05, 2010 10:47 am

It makes sense :) Just wondering if it's really necessary to process non-cef control messages on the application message queue to have javascript run.

Thing is that I have situations where when I execute javascript then call cef_do_message_loop_work it will process pending messages which will in it's turn delete the cef control. Anyway I've changed the code to prevent any actions over a cef control while it's running inside a call to cef_do_message_loop_work so I've got things working fine, not a major obstacle but a bit hassle.

Please be aware I haven't take a look into the CEF control source code, I'm plainly using it's C API interface and mostly ignoring it's inner workings.

btw. Thanks for your AWESOME WORK!!! ;) It's excellent to have Chromium so neatly embeddable using a plain C interface.
carlosb007
Newbie
 
Posts: 9
Joined: Thu Apr 01, 2010 2:50 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 63 guests