`

MathJax+MathML

 
阅读更多
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">

<script src="http://cdn.mathjax.org/mathjax/1.1-latest/MathJax.js">
 MathJax.Hub.Config({
  config: ["MMLorHTML.js"],
  jax: ["input/MathML","output/HTML-CSS","output/NativeMML"],
  extensions: ["mml2jax.js","MathMenu.js","MathZoom.js"]
});
</script>

<script type="text/JavaScript">
var content = ["<math xmlns=\" http://www.w3.org/1998/Math/MathML\"> <mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mo>&#x2212;</mo><mi>b</mi><mo>&#x00B1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>&#x2212;</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow></math>",'<math xmlns="http://www.w3.org/1998/Math/MathML"> <mroot> <mrow><mn>2</mn></mrow> <mrow><mn>1</mn></mrow> </mroot></math>'];
var index = 0;
function a() {
	try {
	    var now=content[index];
	    if(index==0){	  
		  index=1;
		}else{
		  index=0
		}
		document.getElementById("test").innerHTML = now;
		UpdateMath("test");
	}
	catch (e) {
		alert(e.message);
	}
}		
</script>
<script>
(function () {
	window.UpdateMath = function (elementID) {
		MathJax.Hub.Queue(["Typeset", MathJax.Hub, elementID]);
	};
})();
</script>
	</head>
	<body>



		<input type="button" onclick="UpdateMath('MathOutput');"
			value="onclick"></input>

		<div id="MathOutput">
			<math xmlns="http://www.w3.org/1998/Math/MathML">
			<mroot>
			<mrow>
			<mn>
			2
			</mn>
			</mrow>
			<mrow>
			<mn>
			1
			</mn>
			</mrow>
			</mroot>
			</math>
		</div>

		<div id="test"></div>
		<input type=button name="a" value="click" onclick="a()" />

	</body>
</html>
 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics