我有一個包含textarea的頁面。用戶將在其中輸入mathML,當用戶點擊輸出按鈕時,MathML應該呈現並顯示在textarea下。但渲染沒有發生。 Textarea可能包含多個用於渲染的mathml代碼。MathML沒有呈現並顯示在textarea下面
下面是我用過的代碼。
<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'方案運行該頁面? – Oriol 2014-09-28 15:12:12
是的,我已經毀了,但沒有提到,因爲我已經提到。 – 2014-09-28 15:29:56
你在找什麼輸出?當我測試你的代碼時,它似乎工作正常。然而,從搜索來看,只有Firefox和Safari支持正確渲染MathML,而這正是我在我的計算機上看到的在IE,Firefox和Chrome上測試代碼的情況,只有Firefox正確地渲染了它。 – peterjb 2014-09-28 16:50:43