【发布时间】:2019-05-15 13:26:11
【问题描述】:
我有一个使用 MathJax 的测试代码,它显示一些编号和可参考的数学方程式,以及一个旨在在浏览器中打开具有相同数学内容的新窗口的按钮...
<!DOCTYPE html>
<html>
<head>
<title>MathJax Equation References</title>
<!-- Copyright (c) 2012-2013 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX","output/HTML-CSS"],
extensions: ["tex2jax.js"],
tex2jax: {
inlineMath: [["$","$"],["\\(","\\)"]],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
TeX: {
extensions: ["AMSmath.js"],
equationNumbers: { autoNumber: "AMS" } //automatic eqn numbering !!!
}
});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
</head>
<body>
<div id="content">
In equation \eqref{eq:sample}, we find the value of an
interesting integral:
\begin{equation}
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}
\end{equation}
<h1>A test of Equation References</h1>
<hr>
Here is a labeled equation:
\begin{equation}x+1\over\sqrt{1-x^2}\label{ref1}\end{equation}
with a reference to ref1: \ref{ref1},
and another numbered one with no label:
$$x+1\over\sqrt{1-x^2}$$
This one uses \nonumber:
$$x+1\over\sqrt{1-x^2}\nonumber$$
<hr>
Here's one using the equation environment:
\begin{equation}
x+1\over\sqrt{1-x^2}
\end{equation}
and one with equation* environment:
\begin{equation*}
x+1\over\sqrt{1-x^2}
\end{equation*}
<br><br><br>
<hr>
</div>
<button onclick="myFunction()">Try it</button>
<br><br><br>
<script>
var contents=document.getElementById("content").innerHTML;
function myFunction(){
var myWindow = window.open("", "_blank", "toolbar=yes,width=400,height=400");
myWindow.document.write(' <!DOCTYPE html><html><head><title>MathJax Equation References</title><!-- Copyright (c) 2012-203 The MathJax Consortium --><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ jax: ["input/TeX","output/HTML-CSS"], extensions: ["tex2jax.js"], tex2jax: { inlineMath: [["$","$"],["\\(","\\)"]], displayMath: [ ["$$","$$"], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true }, TeX: { extensions: ["AMSmath.js"], equationNumbers: { autoNumber: "AMS" } //automatic eqn numbering !!! } }); </scr'+'ipt><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></scr'+'ipt></head><body>'+contents+'</div><br><br><br></body></html>');
setTimeout(function(){ myWindow.stop(); }, 15000); // assures that the windows stop loading after at most 15s
}
</script>
</body>
</html>
但是新页面中的数学内容没有在页面加载时呈现,任何关于如何修复它的线索?主窗口和新窗口中的<head> 标签是一样的...
提前致谢
【问题讨论】:
标签: html mathjax new-window