我忘了说
我的脚本是写在xsl里面的
html里面没有问题

解决方案 »

  1.   

    代码如下
    <?xml version="1.0" encoding="gb2312"?>
    <xsl:stylesheet 
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
    xmlns="http://www.w3.org/TR/REC-html40" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:user="http://streamsea.svcg.cn/" 
    version="1.0">
    <msxsl:script language="javascript" implements-prefix="user"> 
    var bln = true;
    function getcolor()
    {
    if(bln == true)
    {
    bln = false;
    return "#FFFFFE";
    }
    else
    {
    bln = true;
    return "#EEEEEE";
    }
    }
    </msxsl:script>
    <xsl:template match="/">
    <html>
    <head>
    <title>系统日志</title>
    <style type="text/css">
    <xsl:comment>
    <![CDATA[
    .tablefont {
    font-family: "宋体", "新宋体";
    font-size: 13px;
    color: #333330;
    }
    ]]>
    </xsl:comment>
    </style>
    <script language="JavaScript">
    <![CDATA[
    var hkey_root,hkey_path,hkey_key
    var bln = true;
    hkey_root="HKEY_CURRENT_USER"
    hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
    //设置网页打印的页眉页脚为空
    function pagesetup_null()
    {
      try 
     { 
      var Wsh=new ActiveXObject("WScript.Shell"); 
      HKEY_Key="header"; 
      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P"); 
      HKEY_Key="footer"; 
      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d"); 
     } 
     catch(e){alert (e);
    } }
    ]]>
    </script>
    </head>
    <body topmargin="0" bottommargin="0" rightmargin="0" leftmargin="0" onload="javascript:pagesetup_null()">
    <table align="center" width="610" border="1" cellpadding="0" cellspacing="1" bordercolor="#CCDDEE" class="tablefont">
      <tr align="center" bgcolor="#EFEFEF">
        <th  height="30" colspan="6" scope="col"><font size="4" color="#000000">系统日志</font></th>
      </tr>
      <tr align="center" bgcolor="#CCCCCC">
        <th width="40"  height="20" align="center" scope="col">序号</th>
        <th width="140" scope="col">接收时间</th>
        <th width="80"  scope="col">事件类型</th>
        <th width="160" scope="col">事件源</th>
        <th width="60"  scope="col">操作员</th>
        <th scope="col">描述</th>
      </tr>
     <xsl:for-each select = "SystemLogs/SystemLog">
      <xsl:sort select="no" data-type="number"/><!--以no排序,data-type是数据类型 text/number(文本或数字)-->
      <tr>
      <xsl:attribute name="bgcolor">
       <xsl:value-of select="user:getcolor()"/>
      </xsl:attribute><!-- 为tr添加一个名为bgcolor的属性,值由script脚本得到,也可以直接从xml中读取-->
        <td align="center"><xsl:value-of select="no"/></td>
        <td><xsl:value-of select="timeStamp"/></td>
        <td><xsl:value-of select="category"/></td>
        <td><xsl:value-of select="source"/></td>
        <td><xsl:value-of select="operatorName"/></td>
        <td><xsl:value-of select="description"/></td>
      </tr>
     </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>大家可以保存下来试试