JavaFXAceEditor

JavaFXAceEditor,java,javascript,javafx,Java,Javascript,Javafx,我在WebView中初始化Ace编辑器时遇到问题。HTML的内容显示在示例文本中,但如果我试图调用HTML中的javascript函数,则什么也不会发生。javascript文件与HTML文件位于同一文件夹中 HTML的内容 <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html

我在WebView中初始化Ace编辑器时遇到问题。HTML的内容显示在示例文本中,但如果我试图调用HTML中的javascript函数,则什么也不会发生。javascript文件与HTML文件位于同一文件夹中

HTML的内容

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="ace.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="editor.css">
</head>
<body>
    Sample text
</body>
    <script type="text/javascript">     
    var editor = document.createElement( 'div' );
    editor.id = "editor";
    editor.style.position = 'absolute';
    editor.style.left = '0px';
    editor.style.top = '0px';
    editor.style.width = window.innerWidth + 'px';
    editor.style.height = window.innerHeight + 'px';
    document.body.appendChild( editor );

    var ace = ace.edit("editor");
    ace.setTheme("ace/theme/chrome");
    ace.getSession().setMode("ace/mode/xml");
</script>
</html>

谢谢

您正在尝试运行哪个js代码?它在普通的Chrome浏览器中工作吗?在浏览器(如Firefox)中,它在eclipse浏览器中也工作得很好。我刚刚尝试添加一个元素编辑您的问题,并添加您试图运行的html代码。
WebEngine webEngine = ((WebView)scene.lookup("#myWebView")).getEngine();
webEngine.load(getClass().getResource("../../../html/editor.html").toExternalForm());