Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem calling javascript output by xml/xsl transform

    I have a page where part of the content is gotten by loading an xml file through javascript, then an xsl document used to transform that to html, then document.write-ing that resulting html, like:

    Code:
    function loadXML(url){
    	var xml = new ActiveXObject("Microsoft.XMLDOM");
    	var xsl = new ActiveXObject("Microsoft.XMLDOM");
    	xsl.async = false;
    	xsl.load('the_xsl_file.xsl');
    	xml.onreadystatechange = function () {
    		if (xml.readyState == 4) document.write(xml.transformNode(xsl));
    	};
    	xml.load(url);
    }
    Part of the output of the xml-xsl transform are <script> tags with calls to some javascript functions inside them. The problem I'm having is that when I open this page locally just to test it out, everything works fine, and the code inside the <script> tags output by xsl get called like they're supposed to. But when I put it up on a web server to test it out, none of that code gets called and my page breaks.

    I can't figure out what's preventing that from being called when it's on the web but doesn't prevent it when I open it locally. I'd really appreciate help on this.

    thanks.

  • #2
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just bumping this up... I could really use some help on this

    thanks

  • #3
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    We need access to all your code.
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).

  • #4
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok I've narrowed down what the problem is...

    I'm loading an xml and xsl file with javascript in my page, then writing the transformation output to the page:

    Code:
    function loadXML(url){
    	var xml = new ActiveXObject("Microsoft.XMLDOM");
    	var xsl = new ActiveXObject("Microsoft.XMLDOM");
    	xsl.async = false;
    	xsl.load('the_xsl_file.xsl');
    	xml.onreadystatechange = function () {
    		if (xml.readyState == 4) document.write(xml.transformNode(xsl));
    	};
    	xml.load(url);
    }
    I'm calling that function within the <body>, after having also loaded an external .js file in the <head>. Part of the html that the transformation outputs are script tags that depend on what's in the external file.

    Here's the problem: when I open the file locally everything works fine, the output fills the <body> with what I want, and the functions defined in the external script file get called. But when I put it up on the web (one of my company's development servers) the xml/xsl output looks like it's completely overwriting everything else in the page, including where I load the other javascript file, so it can't find it when I try and call its functions.

    So then my question is why is it overwriting everything else in my page and how can I stop it from doing this?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •