图片轮换代码【原创】

一、静态页面

1、htm页面

<HTML lang=zh xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">

<HEAD>

<TITLE>世纪佳缘交友网_中国最好的严肃婚恋网站</TITLE>

<SCRIPT src="lunhuan_files/global.js" type=text/javascript></SCRIPT>

<META content="MSHTML 6.00.3790.2920" name=GENERATOR></HEAD>

<BODY>

<DIV     id=story_flash></DIV>

<A href="javascript:goUrl()" target=_self>

<SCRIPT type=text/javascript>

url_0="/parties/mlhn/";

img_0="lunhuan_files/1.jpg";

url_1="/story/detail.php?sid=10665";

img_1="lunhuan_files/2.jpg";

url_2="/story/detail.php?sid=10672";

img_2="lunhuan_files/3.jpg";

url_3="/story/detail.php?sid=10675";

img_3="lunhuan_files/4.jpg";

url_4="/story/detail.php?sid=10687";

img_4="lunhuan_files/5.jpg";

var focus_width=430

var focus_height=175

var text_height=0

var swf_height = focus_height+text_height

var pics =img_0+"|"+img_1+"|"+img_2+"|"+img_3+"|"+img_4

var links=url_0+"|"+url_1+"|"+url_2+"|"+url_3+"|"+url_4

var texts = '';

var focus = 'lunhuan_files/focus.swf';

love21cnstory('story_flash',focus, focus_width,swf_height,pics,links,texts)

</SCRIPT>

</A>

</BODY>

</HTML>

2、global.js

function my_getbyid(id)

{

      itm = null;

      if (document.getElementById)

      {

         itm = document.getElementById(id);

      }

      else if (document.all)

      {

         itm = document.all[id];

      }

      else if (document.layers)

      {

         itm = document.layers[id];

      }

   

      return itm;

}

function love21cnFlash(element,url,width,height)

{

if (!my_getbyid(element)) return;

var str = '';

str += '<object width="'+ width +'" height="'+ height +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,9,0" width="'+ width +'" height="'+ height +'">';

str += '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+url+'"><param name="quality" value="high"><param name="bgcolor" value="#ffffff">';

str += '<param name="menu" value="false"><param name=wmode value="opaque">';

str += '<param name="FlashVars" value="pics='+images+'&amp;links='+links+'&amp;texts='+texts+'&amp;borderwidth='+width+'&amp;borderheight='+height+'&amp;textheight=0">';

str += '<embed src="'+url+'" wmode="opaque" FlashVars="pics='+images+'&amp;links='+links+'&amp;texts='+texts+'&amp;borderwidth='+width+'&amp;borderheight='+height+'&amp;textheight=0" menu="false" bgcolor="#ffffff" quality="high" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

str += '</object>';

my_getbyid(element).innerHTML = str;

}

二、动态页面

1.lunhuan.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="lunhuan.aspx.cs" Inherits="lunhuan" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

     <title>无标题页</title>

<SCRIPT src="lunhuan_files/global.js" type=text/javascript></SCRIPT>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

</head>

<BODY>

<form id="form1" runat="server">

<DIV   id=story_flash></DIV>

<A href="javascript:goUrl()" target=_blank>

<%=HuanDeng()%>

</A>

</form>

</body>

</html>

2.lunhuan.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Text;

using System.Data.SqlClient;

public partial class lunhuan : System.Web.UI.Page

{

     protected void Page_Load(object sender, EventArgs e)

     {

         if (!this.IsPostBack)

         {

             HuanDeng();

         }

     }

     public string HuanDeng()

     {

      tt.AccessDAL.NewsArticle newsArticle = new tt.AccessDAL.NewsArticle();

         DataTable dt = newsArticle.GetLunhuan();

         if (dt.Rows.Count==0)

         {

             return "";

         }

       

         StringBuilder builder = new StringBuilder();

         builder.Append("<script>");

         StringBuilder buider2 = new StringBuilder();

         StringBuilder buider3 = new StringBuilder();

         for (int i = 0; i < dt.Rows.Count; i++)

         {

             buider2.Append("\""+dt.Rows[i]["photo"].ToString()+"\"");

             buider3.Append(string.Format("\"lunhuan1.aspx?ID={0}",dt.Rows[i]["ID"].ToString()+"\""));

             if (i != (dt.Rows.Count - 1))

             {

                 buider2.Append("+'|'+");

                 buider3.Append("+'|'+");

             }

         }

         //builder.Append("url_0=\"fffff\" ;\r\n");

         //builder.Append("img_0=\"lunhuan_files/1.jpg\";\r\n");

         //builder.Append("url_1=\"ddd\" ;\r\n");

         //builder.Append("img_1=\"lunhuan_files/2.jpg\";\r\n");

         //builder.Append(" var pics=img_0+' | '+img_1;\r\n");

         //builder.Append(" var links=url_0+'|'+img_1;\r\n");

         builder.Append(" var focus_width=430; var focus_height=175;var text_height=0;var swf_height=focus_height+text_height; \r\n");

         builder.AppendFormat("var pics={0};\r\n", buider2.ToString());

         builder.AppendFormat("var links={0};\r\n", buider3.ToString());

         builder.Append(" var texts=\"\";\r\n");

         builder.Append(" var focus=\"lunhuan_files/focus.swf\";\r\n");

         builder.Append("love21cnstory(\"story_flash\",focus, focus_width,swf_height,pics,links,texts);\r\n");

         builder.Append("</script>");

         return builder.ToString();

     }

}

转载于:https://www.cnblogs.com/tiantangwater/archive/2008/12/24/1361667.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值