views:

144

answers:

1

I have a js file like:

function loadXMLDoc(fname)
{
  var xmlDoc;
  // code for IE
  if (window.ActiveXObject)
    {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation 
     && document.implementation.createDocument)
  {
    xmlDoc=document.implementation.createDocument("","",null);
  }
  else
  {
    alert('Your browser cannot handle this script');
  }
  xmlDoc.async=false;
  xmlDoc.load(fname);
  return(xmlDoc);
}

function displayResult()
{
  xml=loadXMLDoc("Nokia2.xml");
  xsl=loadXMLDoc("UICC.xsl");
  // code for IE
  if (window.ActiveXObject)
  {
    ex=xml.transformNode(xsl);
    document.getElementById("example").innerHTML=ex;
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation 
    && document.implementation.createDocument)
  {
    xsltProcessor=new XSLTProcessor();
    xsltProcessor.importStylesheet(xsl);
    resultDocument = xsltProcessor.transformToFragment(xml,document);
    document.getElementById("example").appendChild(resultDocument);
  }

And i use it in the head of the html file with

<script language="JavaScript" type="text/javascript" src="Content.js"></script>

But it doesn't work, nothing appears in the html. Could anyone tell me why?

BTW: Does IE have addParameter method? If so, please give me an example.

+1  A: 

Where are you calling displayResult?

jdigital
I call it in the body of html, i create a div with id="example", and in the onload event, i call it there