動態flash圖片焦點輪換
前臺:
<!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>
<title></title>
<script type="text/javascript" src="Jscript/jquery-1.7.min.js"></script>
</head>
<body>
<div>
<div>
<div id="ReceivePic" style="display:none"></div>
<script type="text/javascript">
$(function () {
$("#ReceivePic").load("DealPic.ashx", function (data) {
$("#ReceivePic").html(data);
var focus_width = 240
var focus_height = 200
var text_height = 18
var swf_height = focus_height + text_height
var a = $("#ReceivePic").html().split(';');
var pics = a[0];
var texts = a[1];
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
width="' + focus_width + '" height="' + swf_height + '" >');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="images/focus1.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics=' + pics + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">');
document.write('</object>');
});
});
</script>
</div>
</div>
</body>
</html>
ashx:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sql;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace webpicselect
{
/// <summary>
/// DealPic 的摘要說明
/// </summary>
public class DealPic : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Charset = "utf-8";
dealFlash(context);
}
public void dealFlash( HttpContext context)
{
StringBuilder url = new StringBuilder();
StringBuilder imgtext = new StringBuilder();
string sql = "select url,imgtext from FlashPic";
SqlDataReader dr=SqlHelper.GetReader(sql, null,CommandType.Text);
while (dr.Read())
{
url.Append("images/"+dr.GetString(0)+"|");
imgtext.Append(dr.GetString(1)+"|");
}
dr.Close();
url.Remove(url.Length - 1,1);
imgtext.Remove(imgtext.Length-1,1);
string total = "";
total = url.ToString() + ";"+imgtext.ToString();
total.Split(';');
context.Response.Write(total);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.