Search code examples
internet-explorermathjax

Issues with IE 11 and MathJax >2.3 (was: URLs started by slash failing in Internet Explorer)


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!


Solution

  • 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

    1. 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
    2. 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
    3. 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

    4. 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.
    5. 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)