• (XSLT)增强的轮播广告 不及格的程序员


    增强的轮播广告

    <?xml version="1.0" encoding="GB2312" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
     <xsl:output method="html"/>
     
     <xsl:template match="/">
      <img src="{Advertisements/Ad[position()=1]/ImageUrl}" id="imgAd" style="cursor:hand;FILTER: revealTrans(Duration=3.0,Transition=1)"/>
      
      <xsl:value-of select="document('')/*/node()[@name='ScriptData']/node()" disable-output-escaping="yes"/>
      <script language="JavaScript">
       <xsl:apply-templates/>
      </script>
     </xsl:template>
     
     <xsl:template match="Advertisements">
            
        <xsl:variable name="ads" select="Ad[Disabled = 'false']"/>
        <xsl:variable name="ads_count" select="count($ads)"/>
        
        var oAD = new Array(<xsl:value-of select="$ads_count"/>);
        var iADCount = <xsl:value-of select="$ads_count"/>
        <xsl:for-each select="$ads">
         <xsl:if test="Type='image'">     
          oAD[<xsl:value-of select="position()-1"/>] = new Object();
          oAD[<xsl:value-of select="position()-1"/>].Type = "image";
          oAD[<xsl:value-of select="position()-1"/>].Image = new Image();
          oAD[<xsl:value-of select="position()-1"/>].Image.src = "<xsl:value-of select="ImageUrl"/>"      
          oAD[<xsl:value-of select="position()-1"/>].onclick = function(){
           if('<xsl:value-of select="NavigateUrl"/>' == ''){
            return false;
           }
           <xsl:variable name ="WinHeight" select="WinHeight"/>
           <xsl:variable name ="WinWidth" select="WinWidth"/>
           <xsl:if test="$WinHeight != '' and $WinWidth != '' ">
            window.open('<xsl:value-of select="NavigateUrl"/>','','left=0,top=0,height=<xsl:value-of select="$WinHeight"/>,width=<xsl:value-of select="$WinWidth"/>');  
           </xsl:if>
           <xsl:if test="$WinHeight = '' or $WinWidth = '' ">
            window.open('<xsl:value-of select="NavigateUrl"/>');  
           </xsl:if>
          }
         </xsl:if>
         <xsl:if test="Type='swf'">
          oAD[<xsl:value-of select="position()-1"/>] = new Object();
          oAD[<xsl:value-of select="position()-1"/>].Type = "swf";      
          oAD[<xsl:value-of select="position()-1"/>].FileName = "<xsl:value-of select="ImageUrl"/>"      
         </xsl:if>
        </xsl:for-each>
        setScrollPic(<xsl:value-of select="Common/TimeLog"/>);
     </xsl:template>
     
     <xsl:template name="ScriptData">
      <![CDATA[
       <script language="JavaScript">
        transeffect = 0;
        theeffects = new Array(24);
        theeffects[0] = "盒状收缩";
        theeffects[1] = "盒状向外";
        theeffects[2] = "圆形收缩";
        theeffects[3] = "圆形向内";
        theeffects[4] = "从下向上";
        theeffects[5] = "从上向下";
        theeffects[6] = "从左向右";
        theeffects[7] = "从右向左";
        theeffects[8] = "百页窗形向右";
        theeffects[9] = "百页窗形向下";
        theeffects[10] = "棋盘形交叉向右";
        theeffects[11] = "棋盘形交叉向下";
        theeffects[12] = "随意溶解形";
        theeffects[13] = "左右向内";
        theeffects[14] = "左右向外";
        theeffects[15] = "上下向内";
        theeffects[16] = "上下向外";
        theeffects[17] = "条纹状向左下";
        theeffects[18] = "条纹状向左上";
        theeffects[19] = "条纹状向右下";
        theeffects[20] = "条纹状向右上";
        theeffects[21] = "溶解水平状";
        theeffects[22] = "溶解上下状";
        theeffects[23] = "随着溶解";
        
        lastImageNum = 0 ;
        
        function setScrollPic(timelag){
         if(oAD.length > 0)
         {
          if(lastImageNum == iADCount)
          {
            lastImageNum = 0 ;
          }
          if(oAD[lastImageNum].Type == "image")
          {
    
           DeleteSwf();
           document.getElementById("imgAd").style.display = "";
           
           document.getElementById("imgAd").filters.item(0).Apply();
           document.getElementById("imgAd").filters.item(0).Transition = transeffect++;
           document.getElementById("imgAd").filters.item(0).Play(2.0);
    
           document.getElementById("imgAd").src= oAD[lastImageNum].Image.src;
           document.getElementById("imgAd").onclick = oAD[lastImageNum].onclick;
    
           if (transeffect == 24)
           {
            transeffect = 0;
           }              
          }
          else
          {
           document.getElementById("imgAd").style.display = "none";       
           CreateSwf(oAD[lastImageNum].FileName);
          }
          lastImageNum++;
         }
    
         window.setTimeout("setScrollPic("+timelag+")",timelag);
        }
        
        function DeleteSwf(){
         var oSWF = document.getElementById('swfAd');
         if(oSWF != null){
          document.body.removeChild(oSWF);
         }
        }
        
        function CreateSwf(strSwfPath){
         DeleteSwf();
         var oSWF = document.createElement('<embed id="swfAd" src="'+strSwfPath+'" Quality="high" width="274" height="60" Type="application/x-shockwave-flash"></embed>');
         document.body.appendChild(oSWF);     
        }
       </script>  
      ]]>
     </xsl:template> 
    </xsl:stylesheet>
    <?xml version="1.0" encoding="gb2312"?>
    <Advertisements>
      <Common>
        <TimeLog>180000</TimeLog>
      </Common>
      <Ad id="1">
        <Disabled>false</Disabled>
        <Descript>东宇药业晶</Descript>
        <ImageUrl>/img/BQQAd/worldcup01.gif</ImageUrl>
        <NavigateUrl>/index.aspx</NavigateUrl>
        <WinHeight>
        </WinHeight>
        <WinWidth>
        </WinWidth>
        <Type>image</Type>
        <Title>东宇药业</Title>
        <CreateTime>2006-7-14 13:19:13</CreateTime>
      </Ad>
      <Ad id="-1502415828">
        <Disabled>true</Disabled>
        <Descript>test</Descript>
        <ImageUrl>/img/BQQAd/111.swf</ImageUrl>
        <NavigateUrl>
        </NavigateUrl>
        <CreateTime>2006-7-14 13:18:00</CreateTime>
        <WinWidth>
        </WinWidth>
        <WinHeight>
        </WinHeight>
        <Type>swf</Type>
      </Ad>
    </Advertisements>
  • 相关阅读:
    length()
    matlab mod()&rem()
    tf调试函数
    64位win7+PCL1.6.0+VS2010,64位win10+PCL1.6.0+VS2010
    pcl 1.8 + VS 2010 在win7 x64下的配置
    Qt在vs2010下的配置
    VS2010 win7 QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
    [POI2012]ROZ-Fibonacci Representation (贪心)
    CF 666C & 牛客 36D
    数位dp练习
  • 原文地址:https://www.cnblogs.com/ioriwellings/p/4504347.html
Copyright © 2020-2023  润新知