【发布时间】:2014-11-23 01:00:10
【问题描述】:
我有一个包含文本区域的页面。用户将在其中输入 mathML,当用户单击输出按钮时,MathML 应该被渲染并显示在文本区域下方。但是渲染没有发生。 Textarea 可能包含多个用于渲染的 mathml 代码。
下面是我使用的代码。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="file:/P:/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</head>
<body>
<h3>MathML Previewer</h3>
Paste your MathML:<br>
<textarea id="myMath" style="resize: none; height:250px; width:850px">
</textarea>
<button type="button" onclick="myclear()">Reset</button>
<p>Click the button to get output</p>
<button type="button" onclick="myFunction()">Output</button>
<div id="demo">
</div>
</div>
<script>
function myFunction() {
var x = document.getElementById("myMath").value;
document.getElementById("demo").innerHTML = x;
}
</script>
<script>
function myclear() {
var x = document.getElementById("myMath").value =' ';
//document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
【问题讨论】:
-
您是否使用
file方案运行该页面? -
是的,我已经运行但渲染没有发生,正如我提到的那样。
-
您在寻找什么输出?当我测试您的代码时,它似乎工作正常。不过,通过搜索,只有 Firefox 和 Safari 支持正确渲染 MathML,这就是我在计算机上看到的在 IE、Firefox 和 Chrome 上测试您的代码,只有 Firefox 正确渲染了它。
标签: javascript html mathjax mathml