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" οnclick="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" οnclick="a()" />

	</body>
</html>
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值