1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The MathJax.HTML Object — MathJax v1.1 documentation</title>
<link rel="stylesheet" href="../_static/mj.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '1.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<!--<script type="text/javascript" src="../../../MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>-->
<link rel="top" title="MathJax v1.1 documentation" href="../index.html" />
<link rel="up" title="The MathJax API" href="index.html" />
<link rel="next" title="The MathJax.Callback Class" href="callback.html" />
<link rel="prev" title="The MathJax.Message Object" href="message.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="callback.html" title="The MathJax.Callback Class"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="message.html" title="The MathJax.Message Object"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">MathJax v1.1 documentation</a> »</li>
<li><a href="index.html" accesskey="U">The MathJax API</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="the-mathjax-html-object">
<span id="api-html"></span><h1>The MathJax.HTML Object<a class="headerlink" href="#the-mathjax-html-object" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="docutils literal"><span class="pre">MathJax.HTML</span></tt> object provides routines for creating HTML
elements and adding them to the page, and int particular, it contains
the code that processes MathJax’s <a class="reference internal" href="../HTML-snippets.html#html-snippets"><em>HTML snippets</em></a>
and turns them into actual DOM objects. It also implements the
methods used to manage the cookies used by MathJax.</p>
<div class="section" id="properties">
<h2>Properties<a class="headerlink" href="#properties" title="Permalink to this headline">¶</a></h2>
<dl class="describe">
<dt>
<tt class="descname">Cookie.prefix: "mjx"</tt></dt>
<dd><p>The prefix used for names of cookies stored by MathJax.</p>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">Cookie.expires: 365</tt></dt>
<dd><p>The expiration time (in days) for cookies created by MathJax.</p>
</dd></dl>
</div>
<div class="section" id="methods">
<h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline">¶</a></h2>
<dl class="method">
<dt id="Element">
<tt class="descname">Element</tt><big>(</big><em>type</em><span class="optional">[</span>, <em>attributes</em><span class="optional">[</span>, <em>contents</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#Element" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a DOM element of the given type. If <cite>attributes</cite> is
non-<tt class="docutils literal"><span class="pre">null</span></tt>, it is an object that contains <cite>key:value</cite> pairs of
attributes to set for the newly created element. If <cite>contents</cite> is
non-<tt class="docutils literal"><span class="pre">null</span></tt>, it is an <a class="reference internal" href="../HTML-snippets.html#html-snippets"><em>HTML snippet</em></a> that
describes the contents to create for the element. For example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">div</span> <span class="o">=</span> <span class="nx">MathJax</span><span class="p">.</span><span class="nx">HTML</span><span class="p">.</span><span class="nx">Element</span><span class="p">(</span>
<span class="s2">"div"</span><span class="p">,</span>
<span class="p">{</span><span class="nx">id</span><span class="o">:</span> <span class="s2">"MathDiv"</span><span class="p">,</span> <span class="nx">style</span><span class="o">:</span><span class="p">{</span><span class="nx">border</span><span class="o">:</span><span class="s2">"1px solid"</span><span class="p">,</span> <span class="nx">padding</span><span class="o">:</span><span class="s2">"5px"</span><span class="p">}},</span>
<span class="p">[</span><span class="s2">"Here is math: $x+1$"</span><span class="p">,[</span><span class="s2">"br"</span><span class="p">],</span><span class="s2">"and a display $$x+1\\over x-1$$"</span><span class="p">]</span>
<span class="p">);</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
<li><strong>type</strong> — node type to be created</li>
<li><strong>attributes</strong> — object specifying attributes to set</li>
<li><strong>contents</strong> — HTML snippet representing contents of node</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the DOM element created</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="addElement">
<tt class="descname">addElement</tt><big>(</big><em>parent</em>, <em>type</em><span class="optional">[</span>, <em>attributes</em><span class="optional">[</span>, <em>content</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#addElement" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a DOM element and appends it to the <cite>parent</cite> node
provided. It is equivalent to</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">parent</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">HTML</span><span class="p">.</span><span class="nx">Element</span><span class="p">(</span><span class="nx">type</span><span class="p">,</span><span class="nx">attributes</span><span class="p">,</span><span class="nx">content</span><span class="p">))</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
<li><strong>parent</strong> — the node where the element will be added</li>
<li><strong>attributes</strong> — object specifying attributes to set</li>
<li><strong>contents</strong> — HTML snippet representing contents of node</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the DOM element created</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="TextNode">
<tt class="descname">TextNode</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#TextNode" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a DOM text node with the given text as its content.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
<li><strong>text</strong> — the text for the node</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the new text node</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="addText">
<tt class="descname">addText</tt><big>(</big><em>parent</em>, <em>text</em><big>)</big><a class="headerlink" href="#addText" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a DOM text node with the given text and appends it to the
<cite>parent</cite> node.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
<li><strong>parent</strong> — the node where the text will be added</li>
<li><strong>text</strong> — the text for the new node</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the new text node</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="setText">
<tt class="descname">setText</tt><big>(</big><em>script</em>, <em>text</em><big>)</big><a class="headerlink" href="#setText" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the contents of the <tt class="docutils literal"><span class="pre">script</span></tt> element to be the given
<tt class="docutils literal"><span class="pre">text</span></tt>, properly taking into account the browser limitations and
bugs.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
<li><strong>script</strong> — the script whose content is to be set</li>
<li><strong>text</strong> — the text that is to be the script’s new content</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><tt class="docutils literal"><span class="pre">null</span></tt></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">Cookie.Set(name,data)</tt></dt>
<dd><p>Creates a MathJax cookie using the <tt class="docutils literal"><span class="pre">MathJax.HTML.Cookie.prefix</span></tt>
and the <cite>name</cite> as the cookie name, and the <cite>key:value</cite> pairs in
the <cite>data</cite> object as the data for the cookie. For example,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">MathJax</span><span class="p">.</span><span class="nx">HTML</span><span class="p">.</span><span class="nx">Cookie</span><span class="p">.</span><span class="nx">Set</span><span class="p">(</span><span class="s2">"test"</span><span class="p">,{</span><span class="nx">x</span><span class="o">:</span><span class="mi">42</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span><span class="s2">"It Works!"</span><span class="p">});</span>
</pre></div>
</div>
<p>will create a cookie named “mjx.test” that stores the values of
<tt class="docutils literal"><span class="pre">x</span></tt> and <tt class="docutils literal"><span class="pre">y</span></tt> provided in the <cite>data</cite> object. This data can be
retrieved using the <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.HTML.Cookie.Get()</span></tt> method
discussed below.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
<li><strong>name</strong> — the name that identifies the coookie</li>
<li><strong>data</strong> — object containing the data to store in the cookie</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><tt class="docutils literal"><span class="pre">null</span></tt></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">Cookie.Get(name[,obj])</tt></dt>
<dd><p>Looks up the data for the cookie named <cite>name</cite> and merges the data
into the given <cite>obj</cite> object, or returns a new object containing
the data. For instance, given the cookie stored by the example
above,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="nx">MathJax</span><span class="p">.</span><span class="nx">HTML</span><span class="p">.</span><span class="nx">Cookie</span><span class="p">.</span><span class="nx">Get</span><span class="p">(</span><span class="s2">"test"</span><span class="p">);</span>
</pre></div>
</div>
<p>would set <tt class="docutils literal"><span class="pre">data</span></tt> to <tt class="docutils literal"><span class="pre">{x:42,</span> <span class="pre">y:"It</span> <span class="pre">Works!"}</span></tt>, while</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="p">{</span><span class="nx">x</span><span class="o">:</span><span class="mi">10</span><span class="p">,</span> <span class="nx">z</span><span class="o">:</span><span class="s2">"Safe"</span><span class="p">};</span>
<span class="nx">MathJax</span><span class="p">.</span><span class="nx">HTML</span><span class="p">.</span><span class="nx">Cookie</span><span class="p">.</span><span class="nx">Get</span><span class="p">(</span><span class="s2">"test"</span><span class="p">,</span><span class="nx">data</span><span class="p">);</span>
</pre></div>
</div>
<p>would leave <tt class="docutils literal"><span class="pre">data</span></tt> as <tt class="docutils literal"><span class="pre">{x:42,</span> <span class="pre">y:"It</span> <span class="pre">Works!",</span> <span class="pre">z:"Safe"}</span></tt>.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">The MathJax.HTML Object</a><ul>
<li><a class="reference internal" href="#properties">Properties</a></li>
<li><a class="reference internal" href="#methods">Methods</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="message.html"
title="previous chapter">The MathJax.Message Object</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="callback.html"
title="next chapter">The MathJax.Callback Class</a></p>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="callback.html" title="The MathJax.Callback Class"
>next</a> |</li>
<li class="right" >
<a href="message.html" title="The MathJax.Message Object"
>previous</a> |</li>
<li><a href="../index.html">MathJax v1.1 documentation</a> »</li>
<li><a href="index.html" >The MathJax API</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2011 Design Science.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
</div>
</body>
</html>
|