一些文本在JavaFX WebView

时间:2017-06-28 20:04:18

标签: java html intellij-idea javafx webview

我正在开发一个项目,我正在使用JavaFX的WebView和WebEngine来显示HTML网页。我已经让它显示,但我有一个奇怪的错误,其中一些单词是随机着色的。可能很难看到,但这里有一些例子的截图:

unixappend等各种单词的部分显示为紫色:

Parts of various words, like <code>unix</code> and <code>append</code>, appear purple

我查看了HTML源文件,并且没有可以更改其颜色的标记或样式。在Firefox中打开它会将文本显示为完全正常,没有随机颜色。因此,我相信它只发生在WebView中。我在另一台计算机上尝试过这个问题,问题就出现了。

有谁知道发生了什么?如有必要,我可以提供更多描述或部分代码。

编辑:

以下是HTML文件示例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</body>
</html>

此文件显示以下代码行:

String htmlFileURL = SearchToolWindowGUI.class.getResource("lorem.html").toExternalForm();

engine.load(htmlFileURL);

engineWebEngine

的一个实例

我发现这只是加载我自己的HTML文件时的一个问题。如果我这样做:

engine.load("http://www.lipsum.com"),所有着色都是正常的。

以下是示例输出:

Examples are <code>leap</code> being green and <code>into</code> being purple

在Firefox中打开此HTML文件是完全正常的。

0 个答案:

没有答案