原创日志

利用js的cookie实现flash的轮换

[ 2007-03-07 18:01:12 | 作者: admin ]
字号: | |
<script language="javascript1.2">
<!--
       var myCookie="" ;
       //alert(myCookie);
       myCookie = getCookie("myFlash");
       //alert(myCookie);
       if(myCookie==null){
         myCookie = "1";
       }else{
         if(myCookie=="1"){
          myCookie = "2";
        }else{
          myCookie = "1";
        }
       }
       setCookie("myFlash",myCookie);

      

      
       document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"804\" height=\"143\">");
        document.writeln(" <param name=\"movie\" value=\"../image/in"+ myCookie +".swf\">");
        document.writeln(" <param name=\"quality\" value=\"high\">");
        document.writeln(" <embed src=\"../image/in"+ myCookie +".swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"804\" height=\"143\"></embed>");
        document.writeln(" </object>");
      
  //-->
  </script>

<script language="javascript" >
<!--

function setCookie(name,value)
{
/*
  *--------------- setCookie(name,value) -----------------
  * setCookie(name,value)
  * 功能:设置得变量name的值
  * 参数:name,字符串;value,字符串.
  * 实例:setCookie('username','baobao')
  *--------------- setCookie(name,value) -----------------
  */
        var Days = 30; //此 cookie 将被保存 30 天
        var exp = new Date();
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function getCookie(name)
{
/*
  *--------------- getCookie(name) -----------------
  * getCookie(name)
  * 功能:取得变量name的值
  * 参数:name,字符串.
  * 实例:alert(getCookie("baobao"));
  *--------------- getCookie(name) -----------------
  */
        var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
        if(arr !=null) return unescape(arr[2]); return null;
}

//-->
</script>
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=824

这篇日志没有评论。

此日志不可发表评论。