我遇到了包含" .js"在Javafx中为Webview的String内部提供源代码。
我在Codemirror中使用CodeEditor方法,代码如下:
private final String editingTemplate =
"<!doctype html>" +
"<html>" +
"<head>" +
" <link rel=\"stylesheet\" href=\"http://codemirror.net/lib/codemirror.css\">" +
" <script src=\"http://codemirror.net/lib/codemirror.js\"></script>" +
" <script src=\"http://codemirror.net/mode/clike/clike.js\"></script>" +
"</head>" +
"<body>" +
"<form><textarea id=\"code\" name=\"code\">\n" +
"${code}" +
"</textarea></form>" +
"<script>" +
" var editor = CodeMirror.fromTextArea(document.getElementById(\"code\"), {" +
" lineNumbers: true," +
" matchBrackets: true," +
" mode: \"text/x-java\"" +
" });" +
"</script>" +
"</body>" +
"</html>";
这里我要替换&#34; .js&#34;来自CDN与本地&#34; .js&#34;文件,所以不需要连接。
" <link rel=\"stylesheet\" href=\"http://codemirror.net/lib/codemirror.css\">" +
" <script src=\"http://codemirror.net/lib/codemirror.js\"></script>" +
" <script src=\"http://codemirror.net/mode/clike/clike.js\"></script>" +
我找不到正确的语法,文件在我的src文件夹中作为&#34; mypackage / libs / codemirrior.js&#34;例如。
希望有人可以帮助我。
提前致谢!
答案 0 :(得分:0)
webEngineInstance.executeScript(editingTemplate);