• enjosymath

    (@enjosymath)


    The help page on including js file for newbies, must be outdated, because it says to put your “<script>…” line in your header.php. What header.php? Then the simple task of finding my header.php or equivalent becomes a nightmare. I’m not interested in knowing the inner workings of WP at the moment – I just want to include a js file. Like so:

    <script type=”text/javascript”
    src=”http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML”&gt;
    </script>

    Grazie.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Josh

    (@josh401)

    I’m not interested in knowing the inner workings of WP at the moment – I just want to include a js file.

    Well, there are a few different ways. Do you need it included on every page on your site? Do you just need it included on one page?

    The header.php can be found by going to appearance -> editor. Then, select your theme from the dropdown, and click on header.php in the list. It will load the file into the content editor window.

    peter achutha

    (@peter-achutha)

    I tested your math script but I had to remove config=TeX-AMS-MML_HTMLorMML part before it was visible and it gave me this error message:-

    MathJax no longer loads a default configuration file; you must specify such files explicitly. This page seems to use the older default config/MathJax.js file, and so needs to be updated. This is explained further at

    http://www.mathjax.org/help/configuration

    I did it by putting your script in a widget. Widgets will run java scripts. From my experience WP will strip all scripts from the body of your post.

    Alternatively you could put your java script into an .html file eg test.html and than call this through a iframe tag eg

    <div><iframe style="width: 650px; height: 1300px;" src="http://www.mydomian.com/test.html" ></iframe></div>

    But just to let you know, I tested your javascript in my experimental WP blog and found that your java script does not work in the widgets or with the iframe example above.

    Thread Starter enjosymath

    (@enjosymath)

    All right. I haven’t tested yet, but there’s the MathJax help page for people installing on a certain platform (includes WP):
    http://www.mathjax.org/docs/2.0/platforms/index.html#platforms

    Thread Starter enjosymath

    (@enjosymath)

    All right, apparently you need to specify a config now. I ripped this from Math Stack Exchange (which is the way I want MathJax to work anyway…)

    <script type="text/x-mathjax-config">
                    MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },
                                        tex2jax: { inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ], displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno" },
                                        TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } } },
                                        messageStyle: "none"
                    });
                </script>            <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>

    Just paste that in your header.php per the above instructions on the MathJax platform-specific page for WP, and it should work (at least for a while).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Include a JS (Javascript) into my site’ is closed to new replies.