JavaFX AceEditor

时间:2014-09-25 08:50:25

标签: 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; 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>

初始化WebView

WebEngine webEngine = ((WebView)scene.lookup("#myWebView")).getEngine();
webEngine.load(getClass().getResource("../../../html/editor.html").toExternalForm());

由于

0 个答案:

没有答案