BakedBean wrote:
[color=blue]
> <script type="text/javascript" language="javascript">
> document.write("<br/><br/>simple text<br/><br/>");
> document.write("<math
> xmlns='http://www.w3.org/1998/Math/MathML'><mrow><mn>5</mn><msqrt><mrow><mo>-</mo><mn>1</mn></mrow></msqrt></mrow></math>");
> </script>[/color]
[color=blue]
> as an XHTML page. In the above example the first 2 bits of MathML are
> displayed correctly, but the MathML displayed using the document.write
> is not![/color]
Which browser is that? Mozilla does support mixed namespace XML document
with XHTML and MathML but it does not support document.write in such
documents. Check the JavaScript console, I think it shows a script error
for document.write calls in XHTML documents.
What should be possible in Mozilla is using the W3C Core DOM to create
elements in the MathML namespace e.g.
var mnElement = document.createElementNS(mathMLNamespace, 'mn');
mnElement.appendChild(document.createTextNode('5') );
mrowElement.appendChild(mnElement);
var msqrtElement = document.createElementNS(mathMLNamespace, 'msqrt');
var mrowElement2 = document.createElementNS(mathMLNamespace, 'mrow');
var moElement = document.createElementNS(mathMLNamespace, 'mo');
moElement.appendChild(document.createTextNode('-'));
mrowElement2.appendChild(moElement);
var mnElement2 = document.createElementNS(mathMLNamespace, 'mn');
mnElement2.appendChild(document.createTextNode('1' ));
mrowElement2.appendChild(mnElement2);
msqrtElement.appendChild(mrowElement2);
mrowElement.appendChild(msqrtElement);
mathElement.appendChild(mrowElement);
document.body.appendChild(mathElement);
Or you could use DOMParser to parse a string with MathML markup and then
use importNode.
--
Martin Honnen
http://JavaScript.FAQTs.com/