应用程序运行到浏览器时无法查看数学类型

时间:2015-12-24 10:47:41

标签: webview javafx-8 mathjax

在我的javafx应用程序中,我想使用MathJax技术和JavaFX的WebView显示数学方程式。我已经在我的homepage(希腊文)中加载了该应用程序。 我遇到的问题是,当我下载jar文件并运行它时,一切正常! 但是当我从浏览器内部运行应用程序时,方程式显示不正确:stand alone and in-browser

我使用的代码是

package webmath;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebMath extends Application {

@Override
public void start(Stage primaryStage) {

    WebView webView = new WebView();
    String htmlFile = "info.html";
    webView.getEngine().load(WebMath.class.getResource(htmlFile).toExternalForm());

    StackPane root = new StackPane();
    root.getChildren().add(webView);
    Scene scene = new Scene(root, 300, 250);

    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}

public static void main(String[] args) {
    launch(args);
}

}

并且html文件的内容是

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">               
    <script type="text/javascript"
            src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
    </script>

    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
    </script>         
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({showMathMenu: false});
    </script>  

</head>
<body >       
    <p>text text text text text...</p>
    <p>begin equation:</p>

    \begin{equation}\label{eq1}\tag{1}
        x = \frac{\sqrt{b^2 - 4ac}}{2a}
    \end{equation}

    <p>equation end.</p>
    <p>text text text text text...</p>
</body>

我无法理解出了什么问题。我必须做什么才能使应用程序在浏览器中运行良好?

提前致谢。

0 个答案:

没有答案