views:

152

answers:

2

I need help getting the file to run in Firefox: I have tried adapting scripts so that my file runs in both IE and Firefox but so far it still only works in IE. (The file can be tested at http://www.eyle.org/crosstest.html - simply type the word Mike in the text box using IE (doesn't work in Firefox).The HTML document is:

<!DOCTYPE html PUBLIC 
     "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
        var xmlDoc;
        //loads xml using either IE or firefox
        function loadXmlDoc()
        {
            //test for IE
            if(window.ActiveXObject)
            {
                xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async = false;
                xmlDoc.load("books2.xml");
            }

            //test for Firefox
            else if(document.implementation && document.implementation.createDocument)
            {
                xmlDoc = document.implementation.createDocument("","",null);
                xmlDoc.load("books2.xml");
            }
            //if neither
            else
            {
                document.write("xml file did not load");
            }
        }

        //window.onload = loadXmlDoc();
        var subject;
        //getDetails adds value of txtField to var subject in outputgroup(subject)
        function getDetails()
        {
            //either this or window.onload = loadXmlDoc is needed
            loadXmlDoc();
            var subject = document.getElementById("txtField1").value;
            function outputgroup(subject) 
            {
                var xslt = new ActiveXObject("Msxml2.XSLTemplate");
                var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
                var xslProc;
                xslDoc.async = false;
                xslDoc.resolveExternals = false;
                xslDoc.load("contains3books.xsl");
                xslt.stylesheet = xslDoc;
                xslProc = xslt.createProcessor();
                xslProc.input = xmlDoc;
                xslProc.addParameter("subj", subject);
                xslProc.transform();
                document.write(xslProc.output);
            }
            outputgroup(subject);
        }

    </script>
</head>

<body>
    <input type="text" id="txtField1">
    <input type="submit" onClick="getDetails(); return false">
</body>
</html>

The file includes books2.xml and contains3books.xsl (I have put the code for these files at ...ww.eyle.org/books2.xml ...ww.eyle.org/contains3books.xsl) (NB: replace ...ww. with http: // www)

A: 

ActiveX is mechanism which helps IE loading other apps/controls in browser itself. It is meant only for IE and no other browser supports it.

Visit the following site for more info:

http://www.reloco.com.ar/mozilla/compat.html

http://support.mozilla.com/en-US/kb/ActiveX

H Sampat
A: 

Your outputgroup function uses an ActiveXObject creation to create an xslt this is IE specific

For mozilla use XSLTProcessor();

eg for firefox

var processor = new XSLTProcessor(); //create object 

xmlDoc = document.implementation.createDocument("","",null);
xmlDoc.load("books2.xml");

xslDoc.load("contains3books.xsl"); 
xslt.stylesheet = xslDoc;
processor.importStylesheet(xslDoc);//import a stylesheet 

var output = processor.transformToFragment(xmlDoc);
Shaun Hare
Thanks for the suggested code but I'm not sure how to use this:tried adding it to //test for Firefox else if(document.implementation xmlDoc.load("books2.xml"); }This didn't work so tried including it inside function outputgroup(subject){......}Again no joy. Then wondered about your var output = processor.transformToFragment(xmlDoc);var output doesn't seem to be used anywhere.So still want my file to work in both IE and Firefox..further help please
1anthony1