简体   繁体   English

如果从本地js文件加载或者包含源代码,则MathJax无法正常工作

[英]MathJax not working if loaded from local js file or if the source code is included

I am testing the MathJax javascript library in a local HTML file. 我正在本地HTML文件中测试MathJax javascript库。 It works and correctly renders math formulas if I include: 如果我包含以下内容,它可以正确呈现数学公式:

script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'

in the HTML file, but it doesn't work if I include instead: 在HTML文件中,但如果我包含它则不起作用:

script type="text/javascript" src="/path_to/mathjax.js"

or even if I put the entire javascript source code. 或者即使我把整个javascript源代码。 What is the reason? 是什么原因? I need to load mathjax.js from local js file into a local HTML file, so the first way doesn't help me. 我需要将mathjax.js从本地js文件加载到本地HTML文件中,所以第一种方法对我没有帮助。 (EDIT- I see an error: failed to load /extensions/MathZoom.js ) (编辑 - 我看到一个错误: failed to load /extensions/MathZoom.js

I had to load the entire MathJax distribution (17 Mb zip file), expand it and put the right configuration string in the HTML file. 我必须加载整个MathJax发行版(17 Mb zip文件),展开它并将正确的配置字符串放在HTML文件中。 The final form is: script type='text/javascript' src='/path_to/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML,local/local' 最终形式是:script type ='text / javascript'src ='/ path_to / MathJax / MathJax.js?config = TeX-AMS-MML_HTMLorMML,local / local'

This may occur due to two reasons 这可能由于两个原因而发生

1.You may have not extracted the entire zip folder, so first do that. 1.您可能没有提取整个zip文件夹,所以首先要这样做。

Still you are getting the error look into second reason. 你仍然得到错误的第二个原因。

2. You are not referring to the file correctly. 2. 您没有正确引用该文件。 eg: 例如:

<script type ="text/javascript" src="pathto\mathjax.js">

You have typed an incorrect filename. 您输入了错误的文件名。 Correct name of file is MathJax.js.Given below is the correct way. 正确的文件名是MathJax.js.Given下面是正确的方法。

<script type ="text/javascript" src="pathto\MathJax.js">

MathJax.js is the name of the file in the extracted folder(unless modified) MathJax.js是解压缩文件夹中文件的名称(除非已修改)

If all of this is not working,then link to the script in this way: 如果所有这些都不起作用,那么以这种方式链接到脚本:

<script type="text/javascript" src="Pathto\MathJax.js?config=TeX-AMS-MML_HTMLorMML">

The reason that your script is not working is you are not including: 您的脚本无法正常工作的原因是您不包括:

'?config=TeX-AMS-MML_HTMLorMML' '?配置= TEX-AMS-MML_HTMLorMML'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM