The usual way to load jsMath is with a Loading jsMath in the Document HEAD
SCRIPT
command within theBODY
of the document. This is because jsMath need to be able to write content to the body of the document (like the HTML needed to produce the jsMath button at the lower right of the page). There are also other, subtler items that must be written to document body as it is being created that can not be included during theBODY
'sonLoad
handler, for example.It may be better for some authors to be able to load
jsMath.js
in the documentHEAD
rather then theBODY
(for example, if you are trying to add jsMath to a content-management system that doesn't have a convenient means of adding fixed content to the document body). For this reason, the portion of jsMath that must run in the document body has been isolated into a single routine, so you can loadjsMath.js
in the documentHEAD
(where it will know not to run theBODY
routine), but then you have to runjsMath.Setup.Body()
yourself somewhere in the body of the document. ThejsMath.Process()
orjsMath.ProcessBeforeShowing()
commands can run in theBODY
'sonLoad
hander, so the only thing (other than theSPAN
andDIV
tags that mark the mathematics itself) that must be in the body of the document is thejsMath.Setup.Body()
call itself.Note that
jsMath.Setup.Body()
really must be within theBODY
of the document, not theonLoad
handler, or it may not operate properly in some browsers. It is OK to runjsMath.Setup.Body()
more than once (for example, before everySPAN
orDIV
used to mark mathematics), because it checks to see if it has already been run before it does anything. So if you are adding jsMath to a bulletin-board or blog system where you can insert text into the page based on tags entered by the user, it is OK to insert<SCRIPT>jsMath.Setup>Body()</SCRIPT><SPAN CLASS="math">at the beginning of the math and</SPAN>at the end.It is possible to leave
jsMath.Setup.Body()
to the very bottom of the page, just before thejsMath.Process()
orjsMath.ProcessBeforeShowing()
call, but this is not recommended. One action thatjsMath.Setup.Body
takes is to set up the styles used by jsMath, and if portions of the page have already been displayed beforejsMath.Setup.Body
runs, the rendering of the page might change drastically, causing visual confusion for your reader.
|
|