JBCefBrowser executeJavaScript() not work

Answered
Hello
 
I need to modify JBCefBrowser content using JavaScript. I'm trying to modify html content in JBCefBrowser like this, but by some reasons it doesn't work
browser.cefBrowser.executeJavaScript(jsQuery.inject("document.getElementById('input-id').value = 'Hello here'"), "", 0)
 
Could someone help?

Thank you!
 
0
3 comments

Found an issue. For me it works

 

browser.cefBrowser
.executeJavaScript("clickedOnFile('$ideEventObject', '$fileOrFolderPath', '$fileContent', '$filesInFolder')", "", 0)
0

Could you please show more code. How do you create jsQuery?

0
For example,
JBCefBrowser browser = new JBCefBrowser();
JBCefJSQuery jsQuery = JBCefJSQuery.create((JBCefBrowserBase) browser);

jsQuery.addHandler((result) -> {
System.out.println(result);
return new JBCefJSQuery.Response("IntelliJ Ide");
});

String injectedJavaScript = "window.javaCallback = function(param) {"
+ "try {"
+ jsQuery.inject("param")
+ ";"
+ "return true;"
+ "} catch(ex) {alert(ex)}"
+ "}";

browser.getCefBrowser().executeJavaScript(injectedJavaScript, browser.getCefBrowser().getURL(), 0);
0

Please sign in to leave a comment.