PDA

View Full Version : Java Script and Firefox


Tooby
24th November 2005, 21:58
Hi!
Do you know why this work in IE 6 and not Firefox 1.07?
/Tooby

Code example:
----------------------------------------------------------
<html>
<body>
<script type="text/javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("<path and name of file>.xml")
// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("<path and name of file>.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>
-----------------------------------------

Stuff
24th November 2005, 22:18
Firefox thankfully doesn't support ActiveX as the code says " var xml = new ActiveXObject("Microsoft.XMLDOM")"

Check this out for a cross-browser example: W3Schools XML DOM Parser (http://www.w3schools.com/dom/dom_parser.asp)
Also, for the ultimate Mozilla reference, the mozilla developer center (http://developer.mozilla.org/)

Tooby
24th November 2005, 22:51
So if you want to solve this with out ActiveX...How do you do?

I have a XML file and a XSL file that order the the output. I would like to have them on the server and "only" see the htm output. Is there a better/other way to solve it?

/Tooby

Edit: Stuff-Thanx for the links.

Tooby
24th November 2005, 23:20
Thanx! :thumb:
I just found "how" to do it with php. I will have a look at it.

/Tooby

Edit: tried this code and work like charm :)

<?php
$parser = xslt_create();
$html = xslt_process($parser, "xxx.xml",
"xxx.xsl");
xslt_free($parser);

echo $html;
?>