[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

javascript to do an xslt transform after a browser detect

Posted on 2004-11-30
3
Medium Priority
?
302 Views
Last Modified: 2006-11-17
I have a series of XML files that follow a standard schema for filling in content on a web page.  I have an XSLT for Netscape/Mozilla, and XSLT for IE, and several other XSLT's in the works for other browsers.  I want to do a javascript that rewrites the body text of a page with the transform appropriate to the right browser, with a default to IE if the detect fails.
0
Comment
Question by:preserver3
  • 3
3 Comments
 
LVL 25

Expert Comment

by:archrajan
ID: 12711848
<!--
if(-1 != navigator.userAgent.indexOf("MSIE"))
{
 // Internet Explorer
document.write('<LINK YOUR XSLT FILE HERE">');
 }
else if (-1 != navigator.userAgent.indexOf("Mozilla"))
{
// Netscape document.write('<LINK YOUR XSLT FILE HERE');
}
else
{
 // other
document.write('DEFAULT');
} //-->
0
 
LVL 25

Accepted Solution

by:
archrajan earned 2000 total points
ID: 12711870
see this example from w3schools


<html>
<body><script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("cdcatalog.xml")

// Load XSL----------------------------------------------------------> here u can add different xslt's depending on the browser
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cdcatalog.xsl")

// Transform
document.write(xml.transformNode(xsl))</script>

</body>
</html>
0
 
LVL 25

Expert Comment

by:archrajan
ID: 12711889
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question