Forum Moderators: open

Message Too Old, No Replies

xsl and css

         

kennybud416

4:59 am on Jun 14, 2003 (gmt 0)

10+ Year Member



I have the following code in a xsl file that suppose to determine whicy OS I'm using and use the corrected .css file to print.

It doesn't seem to work inside the script tag.

Could someone help me?

<script language="JavaScript1.2">
<!--
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) < 4 )) {
   document.write("<LINK REL=stylesheet HREF=\"ie3.css\" TYPE=\"text/css\">"); }
else if ((navigator.appVersion.indexOf("Mac")!= -1)) {
   document.write("<LINK REL=stylesheet HREF=\"mac.css\" TYPE=\"text/css\">"); }
else {
   document.write("<LINK REL=stylesheet HREF=\"win.css\" TYPE=\"text/css\">"); }
// -->
<xsl:comment>
<xsl:call-template name="henry"/>
<xsl:text>// </xsl:text>
</xsl:comment>
</script>

Thanks in advance

grahamstewart

5:07 am on Jun 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you don't say what version of (x)html your using. But assuming its HTML4.01 or XHTML then your script tag is incorrect.

It should be..

<script type="text/javascript">

See [w3.org...]

The W3C HTML Validator [validator.w3.org] should have told you about this.

kennybud416

6:10 am on Jun 14, 2003 (gmt 0)

10+ Year Member



Sorry I'm new to xhtml. I have posted all of the information below. I tried your suggestion(<script type="text/javascript">) but it didn't work. Hopefully you might be able to advise me on what I'm doing wrong.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<html>
<head>
<script type="text/javascript">
<!--
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) < 4 )) {
document.write("<LINK REL=stylesheet HREF=\"ie3.css\" TYPE=\"text/css\">"); }
else if ((navigator.appVersion.indexOf("Mac")!= -1)) {
document.write("<LINK REL=stylesheet HREF=\"mac.css\" TYPE=\"text/css\">"); }
else {
document.write("<LINK REL=stylesheet HREF=\"win.css\" TYPE=\"text/css\">"); }
// -->
<xsl:comment>
<xsl:call-template name="henry"/>
<xsl:text>// </xsl:text>
</xsl:comment>
</script>

tedster

7:07 am on Jun 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In XHTML, elements and attributes must be lowercase, but your script uses document.write() to create UPPERCASE elements and attributes. So try it with "link", "rel", "href", and "type" in lowercase.

Also a <!DOCTYPE> is mandatory in XHTML. Which one depends on what you are coding.
Here's the W3C Doctype List [w3.org].

kennybud416

11:32 pm on Jun 14, 2003 (gmt 0)

10+ Year Member



I found the problem out. It looks like the script won't run because somebody had javascript code which was written wrong and out side of the "Script" tags. When I removed the code out side of the "Script" tags and I put "<![CDATA[" around the javascript code I wrote everything worked fine.

Strange? But it does work now.

Thanks for all of your help. You help lead me in the right direction. Thanks again.