Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-17-2005, 07:10 PM   PM User | #1
MattL920
New to the CF scene

 
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
MattL920 is an unknown quantity at this point
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.
MattL920 is offline   Reply With Quote
Old 08-18-2005, 03:03 PM   PM User | #2
MattL920
New to the CF scene

 
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
MattL920 is an unknown quantity at this point
Just bumping this up... I could really use some help on this

thanks
MattL920 is offline   Reply With Quote
Old 08-18-2005, 11:16 PM   PM User | #3
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
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).
hemebond is offline   Reply With Quote
Old 08-22-2005, 09:20 PM   PM User | #4
MattL920
New to the CF scene

 
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
MattL920 is an unknown quantity at this point
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?
MattL920 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:04 PM.


Advertisement
Log in to turn off these ads.