How to bind a js callback function

Having problems with building or using the JCEF Java binding? Ask your questions here.

How to bind a js callback function

Postby reamer » Mon May 25, 2020 12:36 am

Hi guys:
I am a new one to JCEF. Now, I want to bind a java function to js window object. Say:
Code: Select all
  public void log(string msg){
    logger.info(msg);
  }


So that i can call it in js codes. Eg:

Code: Select all
  function onload(){
    ...//business logic codes
    window.log('page is loaded');
  }


Is there a way to do it? Or some workaround way is also ok.

Thanks so much!
reamer
Newbie
 
Posts: 4
Joined: Sun May 24, 2020 11:11 pm

Re: How to bind a js callback function

Postby magreenblatt » Mon May 25, 2020 9:26 am

You can use the existing console.log JS function. It will result in a call to CefDisplayHandler. onConsoleMessage.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: How to bind a js callback function

Postby reamer » Thu May 28, 2020 4:12 am

magreenblatt wrote:You can use the existing console.log JS function. It will result in a call to CefDisplayHandler. onConsoleMessage.

thanks for your input.
reamer
Newbie
 
Posts: 4
Joined: Sun May 24, 2020 11:11 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 31 guests