[HOME] jsMath (Authors) [Prev][Up][Skip][Next]

Getting Started with jsMath

Once you have jsMath installed and tested, edit the file jsMath/easy/load.js to suit your needs (see configuring jsMath for more details). In particular, change the setting for root to be the URL for the jsMath folder, wherever you have placed it on your web server or hard disk. The comments in the file should help you decide which values need to be changed. You may make copies of that file, each with different settings, if you need to be able to use jsMath in more than one configuration.

Next, create an html file containing mathematics. Your settings in easy/load.js will determine how you have to indicate the mathematics within your file. For example, with the default settings, you could use \(...\) around in-line math and \[...\] around displayed equations. There is a sample file in jsMath/test/sample.html that should help you with your first document containing mathematics.

Adding jsMath to an HTML document

To use jsMath in a web page, you should add the line
    <SCRIPT SRC="path-to-jsMath/easy/load.js"></SCRIPT>
to the HEAD section of your document. Here, path-to-jsMath should point to the location where you have placed the jsMath package. You can make jsMath be available site-wide by putting it in a place that is easy for many web pages to access (say http://your-host/jsMath/easy/load.js), or you could make jsMath be local to your particular web page by putting it in the same directory as your .html file (in which case jsMath/easy/load.js would be sufficient to locate jsMath).

That's it; jsMath will use the settings in your easy/load.js file to process the mathematics on your page. For example, you should be able to load the jsMath/test/sample.html file and have it display (some of) the mathematics it contains. (Parts of it will not be typeset, because the default settings in easy/load.js have some features of jsMath turned off.)

Some Caveats

You should not load jsMath from a server in a different domain from the one that serves the page that is using jsMath. If you do, jsMath may not be able to load some of its optional components (like the fallback code or the control panel code). This is a restriction placed on jsMath by the JavaScript security model, and is not something that jsMath will be able to overcome. You can, however, load jsMath from another server in the same domain as your main page. For example, if the main page is coming from www.math.union.edu and jsMath is taken from union.edu, then jsMath will still be able to access its optional components. To do this, it sets that document.domain for the main page to be the largest common domain between the two addresses.

Since jsMath requires JavaScript to be turned on in order to display your mathematics, it is a good idea to include something like

    <DIV STYLE="color:#CC0000; text-align:center">
      <B>Warning: <A HREF="http://www.math.union.edu/locate/jsMath">jsMath</A>
      requires JavaScript to process the mathematics on this page.<BR>
      If your browser supports JavaScript, be sure it is enabled.</B>
at the top of your HTML file. This will give your readers a message informing them that they should turn on JavaScript if they have it off. Note that this must be included in the body of your document, and can't be inserted by jsMath (since if JavaScript is turned off, there is no way for jsMath to modify the page).

Get jsMath at SourceForge.net. Fast, secure and Free Open Source software downloads [HOME] jsMath web pages
Created: 10 Jul 2005
Last modified: Mar 28, 2010 3:09:30 PM
Comments to: dpvc@union.edu
[Next] Configuring jsMath
[Skip] Browser Support for jsMath
[Up] Information for jsMath Authors
[Prev] Installation and Testing