IE 11和MathJax> 2.3的问题(是:在Internet Explorer中由斜杠启动的URL失败)(Issues with IE 11 and MathJax >2.3 (wa

编程入门 行业动态 更新时间:2024-10-10 17:25:56
IE 11和MathJax> 2.3的问题(是:在Internet Explorer中由斜杠启动的URL失败)(Issues with IE 11 and MathJax >2.3 (was: URLs started by slash failing in Internet Explorer))

编辑:以下问题是由两个页面之间的唯一区别提示的,一个正常工作而另一个正常; 看下面的答案。

IE(至少版本11和12)似乎不接受诸如此类的URL

/a/b.js

用在像上下文中

<script type="text/javascript" src="/a/b.js"></script>

如果不使用表单的URL,我将不胜感激如何避免这个问题

http://somedomain/a/b.js

(不使用它的原因是某些浏览器接受,例如,

xyz

作为意义

http://www.xyz

但是然后通过错误地应用同源策略来阻止使用从最后一行开始的URL的资源。

在此先感谢您的帮助!

EDIT: the following question was prompted by what seemed the only difference between two pages, one working correctly but not the other; see my answer below.

It seems that IE (at least versions 11 and 12) does not accept URLs such as

/a/b.js

used in contexts like

<script type="text/javascript" src="/a/b.js"></script>

I would appreciate any help on how to avoid this problem without resorting to using a URL of the form

http://somedomain/a/b.js

(the reason to not use this is that some browsers accept, eg.,

xyz

as meaning

http://www.xyz

but then block the use of resources with URLs starting as this last line by wrongly applying the Same Origin Policy).

Thanks in advance for any help!

最满意答案

我提出这个问题是因为页面中存在使用斜杠启动URL但在使用完整URL的类似页面中存在问题。 感谢@CBroe的评论,经过更多测试后,现在可以清楚地看到检测到的问题不是由URL中使用的语法引起的。 相反问题是IE(至少版本11和12)不会在某些页面中呈现MathJax公式,而不是在所有页面中呈现MathJax公式,并且有时,但并不总是使用相同的页面,在正确的情况下会出现JS语法错误声明。

更新:在获得MathJax团队的Peter Krautzberger和David Cervone的更多帮助后( https://groups.google.com/forum/#!topic/mathjax-users/hTq9MxEVYI0 )以及更多测试结果如下

使用MathJax 2.2进行大约一年前的测试时,问题没有出现; IE的自动更新和/或MathJax从2.2到2.4和2.5.1的更改导致它发生 问题是由于MathJax配置在页面中给出的 <script type="text/x-mathjax-config"> <!-- MathJax.Hub.Config({ ... }); --> </script> <script type="text/x-mathjax-config"> <!-- MathJax.Hub.Config({ ... }); --> </script>而页面中的所有其他脚本,也以相同的方式使用HTML注释分隔符,按预期工作 这些注释分隔符用于隐藏脚本内容,特别是用于使用W3C标记验证器,但是

关闭HTML注释分隔符应该在Wavascript评论中,如W3C HTML 4.01 TR 18.3.2 [1999]中所述(我不能发布超过2个链接...)但这不能解决问题 这些页面是在XHTML 1.0中,而不是这些分隔符,代码应该在CDATA部分,即内部 //<![CDATA[ ... //]]> (请参阅脚本标记中何时需要CDATA部分? )这样就解决了问题

避免此问题的另一种方法是将MathJax配置放在一个文件中,该文件的URI在脚本的“src”属性中给出( type="text/javascript" ); 文件内容不需要HTML注释或CDATA部分; 必须使用MathJax配置的新语法,即对window.MathJax对象的赋值。 后者是首选的解决方案,因为虽然在XHTML 1.0中,页面被用作HTML,但是分隔符的选择变得复杂; 只要遵循一些兼容性规则,就可以将XHTML作为HTML提供,请参阅W3C关于提供XHTML(概述)的文章和XHTML 1.0 TR兼容性指南(同样我不能发布超过2个链接)

I put this question because there were problems in a page using slash started URLs but not in a similar page using full URLs. Thanks to the comments by @CBroe and after more testing it is now clear that the issues detected are not caused by the syntax used in URLs. Instead the problems are with IE (versions 11 and 12, at least) that does not render MathJax formulas in some, but not all pages, and that sometimes, but not always even with the same page, gives a JS syntax error in a correct statement.

UPDATE: after getting more help from Peter Krautzberger and David Cervone of the MathJax team (https://groups.google.com/forum/#!topic/mathjax-users/hTq9MxEVYI0) and more tests the conclusions are as follows

The problem did not show up when tests were made about a year ago with MathJax 2.2; automatic updates to IE and/or changes in MathJax from 2.2 to 2.4 and 2.5.1 caused it to occur The problem resulted from the MathJax configuration being given in the pages as <script type="text/x-mathjax-config"> <!-- MathJax.Hub.Config({ ... }); --> </script> while all other scripts in the pages, also using the HTML comment delimiters in the same way, worked as expected These comment delimiters were used for hiding the script contents, in particular for using the W3C markup validator, but

the closing HTML comment delimiter should have been in a Javascript comment as described in W3C HTML 4.01 TR 18.3.2 [1999] (I cannot post more than 2 links...) but this does NOT solve the problem the pages are in XHTML 1.0 and instead of these delimiters the code should be in a CDATA section, i.e., within //<![CDATA[ ... //]]> (see When is a CDATA section necessary within a script tag?) and this solves the problem

Another way of avoiding the problem is to put the MathJax configuration in a file whose URI is given in the "src" attribute of a script (type="text/javascript"); the file contents needs no HTML comments nor CDATA sections; the new syntax for MathJax configurations, i.e., an assignment to the window.MathJax object, must be used. The latter is the preferred solution because, although being in XHTML 1.0, the pages are being served as HTML, what complicates the choice of delimiters; serving XHTML as HTML is ok as long as some compatibility rules are followed, see W3C article on serving XHTML (Overview) and the XHTML 1.0 TR compatibility guidelines (again I cannot post more than 2 links)

更多推荐

本文发布于:2023-08-08 00:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466665.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:斜杠   Internet   Explorer   MathJax   failing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!