I'm trying to insert a String of text into a <h3 class="panel-title"></h3>
element inside a HTML document inside a WebView.
.java
webEngine = webView.getEngine();
String headerText = "This is the Header";
webEngine.executeScript("testCheckMate(" + headerText + ");");
the HTML
<h3 class="panel-title"></h3>
<script>
$(document).ready(function() {
window.testCheckMate = function (data) {
$( ".panel-title" ).append( data );
};
});
</script>
I, however, keep getting the error:
Caused by: netscape.javascript.JSException: SyntaxError: Unexpected keyword 'this'. Expected ')' to end a argument list.
at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:128)
at com.sun.webkit.WebPage.twkExecuteScript(Native Method)
at com.sun.webkit.WebPage.executeScript(WebPage.java:1439)
at javafx.scene.web.WebEngine.executeScript(WebEngine.java:982)
What am I doing wrong?