Up: The WebEQ Math Viewer Applet

Using the Math Viewer in IE5

An exciting feature starting with WebEQ version 2.5 is the ability to use the Math Viewer as a rendering behavior in Internet Explorer 5. In IE5, behaviors are executable code that is associated with elements in the Web page. In the case of the Math Viewer, JavaScript code is associated with the <math> element that takes the MathML code, and replaces it with the appropriate Math Viewer applet. See the DHTML Behaviors Reference at MSDN for more information on using Behaviors in general.

A word of warning. Documents set up to utilize the Math Viewer behavior will only render properly in Internet Explorer 5 and later. At this point there is no very good way to gracefully fallback to images or applets in other browsers. Therefore, you best strategy is probably to create two versions of your documents.

Also, the Math Viewer interactivity features are not availabe when used as a behavior, so you will need to include interactive equations separately via the applet tag as usual.

To set up the Math Viewer as a rendering behavior for the <math> tag, you need to put three lines in the head of your document:

  1. You must declare a namespace prefix for MathML elements. There are several ways to do this. The Wizard does it by including the following XML declaration in the head of the document:
    <xml:namespace prefix="m"/>
  2. You must then add a CSS <style> element that binds the <math> element to WebEQ behavior code that implements the behavior. (The behavior is located in the file mml.htc in the scripts directory of your WebEQ installation.) The necessary style declaration in the document head is:
    <style> m\:math {behavior: url(mml.htc)} </style>
    
    Note that the prefix you use here must match the prefix in the declaration from above. Also, note the backslash, which is necessary in IE.

  3. Finally, you must load a JavaScript file and attach it to a resize event that the Math Viewer generates as part ofthe size negotiation process. This file provides "glue code" that coordinates between the Math Viewer and the broweser. This is done by including the following line in the document header.
    <script for="webeq" event="webeqResize(lbl)" src="webeqResize.js">
    
After adding these declarations to the head of the document, you must then use the namespace prefix on all <math> elements in your document. In our example with the 'm' prefix, this means equations would be marked up like this:
<m:math><mi>x</mi><mo>+</mo><mn>2</mn></m:math>

You can have the Wizard automatically include the necessary behavior initialization code in your documents by checking the "Enable IE5 behaviors" box on the Options panel. You can also specify the namespace prefix there.

Note that the Wizard only generates the namespace prefixes on the <math> element. Technically, all the children elements also need the namespace prefix unless you make a new namespace declaration on the <math> tags which resets the namespace for MathML within the scope of the <math> element. To tell the Wizard to generate the necessary declarations, you should always also check the "Include namespace declarations" box in the Wizard Options. This is worth doing, since it is necessary if you want to generate documents that completely comply with the W3C Namespaces in XML Recommendation. If you do so, your MathML equations will look something like:

<m:math xmlns:m="http://www.w3.org/1998/Math/MathML"
        xmlns="http://www.w3.org/1998/Math/MathML">
    <mi>x</mi><mo>+</mo><mn>2</mn>
</m:math>

Finally, once you have created a document with IE5 behavior declarations, you will ultimately need to make 3 files available on your server:

  • The HTML document itself.
  • A copy of the mml.htc file from the scripts directory of your WebEQ installation.
  • A copy of the webeqResize.js file from the scripts directory of your WebEQ installation.
Of course, you will also need to make the Math Viewer class files or archives available to your reader as well. See the Distributing the Math Viewer Applet from a Web Server for more details.

Example

The sample abstract in the templates directory gives and example of a document set up to use the Math Viewer with IE5 behaviors.


[HOME] WebEQ 2.5 Documentation Table of Contents

Created: Aug 08 1997 --- Last modified: Sun Jul 23 14:05:40 2000
Copyright © 1997-2000 Design Science, Inc. All rights reserved.