wpf webBrowser NavigateToString脚本错误

wpf webBrowser NavigateToString脚本错误,wpf,browser,mathjax,Wpf,Browser,Mathjax,我想使用Wpf webBrowser控件来渲染数学方程。 我已经下载了MathJax,并将其包含在我的VisualStudio项目中 我尝试加载一个示例。这是我正在使用的html代码: <!DOCTYPE html> <html> <head> <title>MathJax MathML Test Page</title> <!-- Copyright (c) 2010-2012 Design Science, Inc. --&g

我想使用Wpf webBrowser控件来渲染数学方程。 我已经下载了MathJax,并将其包含在我的VisualStudio项目中

我尝试加载一个示例。这是我正在使用的html代码:

<!DOCTYPE html>
<html>
<head>
<title>MathJax MathML Test Page</title>
<!-- Copyright (c) 2010-2012 Design Science, Inc. -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<script type="text/javascript" src="MathJax-Reduced/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"></script>

</head>
<body>

<p>
When
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>a</mi><mo>&#x2260;</mo><mn>0</mn>
</math>,
there are two solutions to
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>a</mi><msup><mi>x</mi><mn>2</mn></msup>
  <mo>+</mo> <mi>b</mi><mi>x</mi>
  <mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn>
</math>
and they are
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mi>x</mi> <mo>=</mo>
  <mrow>
    <mfrac>
      <mrow>
        <mo>&#x2212;</mo>
        <mi>b</mi>
        <mo>&#x00B1;</mo>
        <msqrt>
          <msup><mi>b</mi><mn>2</mn></msup>
          <mo>&#x2212;</mo>
          <mn>4</mn><mi>a</mi><mi>c</mi>
        </msqrt>
      </mrow>
      <mrow> <mn>2</mn><mi>a</mi> </mrow>
    </mfrac>
  </mrow>
</math>
</p>

</body>
</html>
但如果我尝试以下代码:

string s = File.ReadAllText(Directory.GetCurrentDirectory() + "\\test-1.html");
this.webBrowser1.NavigateToString(s);
我得到一个脚本错误:

An error has occurred in the script on this page.
Line:    1
Char:    1
Error:   Syntax Error
Code:    0
URL:     about:MathJax-Reduced/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full

怎么了?使用类似于上一个代码的东西会非常有帮助,因此我可以避免保存文件只是为了加载它…

注意,错误中的URL是关于:MathJax Reduced/Unpackage…,这是一个关于
的URL,而不是第一种情况下的
文件://
URL。我怀疑这就是问题的原因。这表明
NavigateToString
函数正在使用
about:blank
或类似的URL作为页面的基本URL,因此MathJax获得了错误的自身路径。请注意,从文件中读取页面并将其作为字符串加载时,会丢失实际页面位置。这意味着您可能必须从绝对URL而不是相对URL加载MathJax(即,包括
文件://
MathJax精简的
目录的路径).

我尝试添加绝对路径:
文件://C$/Users/Davide/Documents/Visual%20Studio%202010/Projects/Test-MathJax-1/Test-MathJax-1/bin/Debug/MathJax-Reduced/unpaced/MathJax.js?config=TeX-AMS-MML\u HTMLorMML-full
\n它不会呈现数学。我尝试使用:
file://127.0.0.1/C$/Users/Davide/Documents/Visual%20Studio%202010/Projects/Test-MathJax-1/Test-MathJax-1/bin/Debug/MathJax-Reduced/unpacket/MathJax.js?config=TeX-AMS-MML_‌​HTMLOMML full
这给了我一个错误:
这个页面上的脚本中发生了一个错误。行:181字符:7错误:无法获取属性“img”的值:对象为null或未定义的代码:0 URL:file://127.0.0.1/C$/Users/Davide/Documents/Visual%20Studio%202010/Projects/Test-MathJax-1/Test-MathJax-1/bin/Debug/MathJax-Reduced/unpacket/jax/output/HTML-CSS/imageFonts.js
MathJax Reduced
建议您已经删除了MathJax发行版的一部分,可能是图像字体(
font/HTML-CSS/TeX/png
文件夹),因为它们构成了MathJax占用的大部分空间。请注意,尝试加载图像字体包时出现故障,这表明它们已被删除。如果不安装图像字体,则需要通过在配置的
“HTML-CSS”
部分中设置
imageFont:null
来通知MathJax。我已经包括了字体文件夹,问题是使用了绝对路径。请看我在加载页面时看到的以下消息:
文件加载失败:file://127.0.0.1/C$/Users/Davide/Documents/Visual%20Studio%202010/Projects/Test-MathJax-1/Test-MathJax-1/bin/Debug/MathJax Reduced/unpacted/。/font/HTML-CSS/TeX/png/unpacted/imagedata.js
路径部分
MathJax精简/解包/./font/HTML-CSS/TeX‌​/png/unpacket/imagedata.js
是正确的。开头的部分正确吗?如果
。/
困扰您,那就是删除
解包
目录,因为字体位于主目录中。不过,我有点惊讶,你首先得到的是图像字体。你在使用Firefox吗?Firefox的
file://
URL是唯一出现这种情况的例子。一个简单的解决方案是在system fonts文件夹中安装MathJax OTF字体。
An error has occurred in the script on this page.
Line:    1
Char:    1
Error:   Syntax Error
Code:    0
URL:     about:MathJax-Reduced/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full