Skip to main content



The MathFlow SDK Editor applets enable you to obtain mathematical input from readers using standard JavaScript and CGI techniques (similar to those for obtaining text input from ordinary HTML form elements like text areas, pulldown menus, etc.). Typical applications for the MathFlow SDK Editor applets include the following:

  • Entering equations into message board postings.

  • Entering answers for online quizzes and tutorials.

As described below, there are five typical steps to be performed when authoring content using the MathFlow SDK Editor applets.

  1. Put the necessary files into the proper locations. The HTML page must specify the relative location of the MathFlow SDK Editor applet.

  2. Setting applet parameters. Parameters can be utilized to customize MathFlow SDK Editor features, such as configuring a custom toolbar or help file.

  3. Writing a JavaScript handler to retrieve a MathML-encoded equation from the MathFlow SDK Editor applet. For example, when readers click the submit button, you want the equation data treated like any other HTML form data. However, since the MathFlow SDK Editor applet isn't a standard HTML form control, some JavaScript programming is required to "hook up" the MathFlow SDK editor applet with the rest of the page.

  4. Process the MathML, which depends on your application.

  5. Return the result. Depending on the application, you will generally need to return a response page to your readers.

Setting applet parameters

In addition to standard attributes common to all applets (e.g., codebase), the MathFlow SDK Editor applets also recognize a number of special, optional parameters. You can customize the MathFlow SDK Editor applets by setting the optional parameters. The MathFlow SDK Editor applet parameters naturally divide into three groups:

  1. Those that customize the MathFlow SDK Editor applet user interface (e.g., the toolbar, the help file, etc.).

  2. Those that affect the equation appearance (e.g. foreground and background colors, initial equation to display if any, etc.).

  3. Those that relate to using the MathFlow SDK Editor applets on a Mac (e.g. JavaScript to Java communication may not work on the Mac, so special steps must be taken to use the MathFlow SDK Editor applets. See Mac Only Applet Parameters for details.).

Complete descriptions of all parameters and their legal values are given in Applet Parameters.

Writing JavaScript handlers

JavaScript is the primary way of querying a MathFlow SDK Editor applet for the MathML markup of the equation it is currently displaying. Thus, integrating the MathFlow SDK Editor applets into your Web applications nearly always requires JavaScript programming.

The basic procedure is fairly simple…

  1. First, place an HTML control, such as a "submit" button, in your page, and specify a JavaScript handler for it.

  2. Then, in the JavaScript handler function, use the MathFlow SDK Editor applet API functions to request the MathML markup for the current equation.

  3. Once the handler function has retrieved the MathML from the MathFlow SDK Editor applet, it is usually necessary to send it back to a Web server for processing. The easiest way of doing so is to have the handler function request the URL of the processing script directly, passing the MathML as an argument to the script. Another common strategy is to store the MathML in a hidden field of a normal HTML form.

  4. When the form is submitted, the MathML is then sent along with the rest of the form data.

For simple tasks, it is often possible to process the MathML using JavaScript within the handler function without going back to a Web server. While client-side processing generally gives a much better user experience than server-side processing, parsing MathML with JavaScript rapidly becomes complex. On a Mac operating system, with browsers other than the Firefox/Mozilla or Chrome browsers, it is not possible to use JavaScript to query the editor. As a workaround, the MathFlow SDK Editor applet automatically detects when it is running on a Mac, and adds controls to its user interface for sending input directly to a CGI script. See Mac Only Applet Parameters for more discussion of the techniques involved.

Processing MathML and returning results

The techniques for processing MathML and returning results are standard. Main examples include:

  1. Producing an image for use in standard HTML. Math capability is often added to message board systems by converting MathML from the MathFlow SDK editor applets into images. The images can then be treated as part of the message board's normal HTML previewing mechanisms. MathFlow SDK Equation Composer is a useful tool for doing the image generation.

  2. Using a server-side script to send the equation to a computer algebra system. Maple and Mathematica have the most advanced MathML support.

  3. Using either client-side JavaScript or server-side scripts to search or pattern-match.