View Full Version : Passing Querystring to XSL param

10-07-2010, 04:29 PM
Hey folks,

I have this hacked together code from some webpage that works in some versions of IE (but not the latest) and does not work in Firefox, etc.

I have seen examples of how to make stuff like this cross-browser, but usually the script is doing something different than I am doing, and I don't know enough about Javascript to adapt it.

Any help?

Another (but less pressing) issue is setting the value to ZZZ if there is no query string. It works if I do an if/else statement on this line:

processor.addParameter("param1", qrystring);

But only if it has a query string with no value (?Code=), not if there is nothing at all.

<script type="text/javascript">
urlstring = location.href;
qrystring=urlstring.substring(urlstring.indexOf("=") + 1, urlstring.length);

//Passing XSL variable
var xml = new ActiveXObject("MSXML2.DomDocument.4.0");
xml.async = false;

var xsl = new ActiveXObject("MSXML2.FreeThreadedDomDocument.4.0");
xsl.async = false;

var template = new ActiveXObject("MSXML2.XSLTemplate.4.0")

template.stylesheet = xsl;
processor = template.createProcessor();

processor.input = xml;
processor.addParameter("param1", qrystring);