ASP.NET 2.0 下 使用 Javascript 和 Flash 制作 图片自动切换效果
Posted on 2008-12-18 22:57 sunrack 阅读(1174) 评论(0) 收藏 举报<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div id="DivFlash">
</div>
<div id="Div1">
</div>
</form>
</body>
</html>
<script type="text/javascript">
var pics=<%=pics%>;
var links=<%=links%>;
var texts=<%=texts%>;
var flashURL="1/pixviewer.swf";
function window.onload()
{
InsertImageViewer(flashURL, "DivFlash", 300, 150, 20, pics, links, texts);
InsertImageViewer(flashURL, "Div1", 200, 100,50, pics, links, texts);
}
function InsertImageViewer(flashURL, targetObj, focus_width, focus_height, text_height, imageList, linkList, titleList)
{
var swf_height = focus_height + text_height;
var divObj = document.getElementById(targetObj);
divObj.innerHTML =
'<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 + '">'
+ '<param name="allowScriptaccess" value="sameDomain">'
+ '<param name="wmode" value="transparent">'
+ '<param name="movie" value="' + flashURL + '">'
+ '<param name="quality" value="high">'
+ '<param name="bgcolor" value=#ffffff>'
+ '<param name="menu" value="false">'
+ '<param name=wmode value="opaque">'
+ '<param name="FlashVars" value="'
+ 'pics=' + imageList
+ '&links=' + linkList
+ '&texts=' + titleList
+ '&borderwidth=' + focus_width
+ '&borderheight=' + focus_height
+ '&textheight=' + text_height + '">'
+ '<embed src="'+ flashURL +'" wmode="opaque" FlashVars="'
+ 'pics=' + imageList
+ '&links=' + linkList
+ '&texts=' + titleList
+ '&borderwidth=' + focus_width
+ '&borderheight=' + focus_height
+ '&textheight=' + text_height
+ '" menu="false" bgcolor=#ffffff quality="high" '
+ 'width="' + focus_width
+ '" height="' + swf_height
+ '" allowScriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
+ '</object>';
}
</script>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div id="DivFlash">
</div>
<div id="Div1">
</div>
</form>
</body>
</html>
<script type="text/javascript">
var pics=<%=pics%>;
var links=<%=links%>;
var texts=<%=texts%>;
var flashURL="1/pixviewer.swf";
function window.onload()
{
InsertImageViewer(flashURL, "DivFlash", 300, 150, 20, pics, links, texts);
InsertImageViewer(flashURL, "Div1", 200, 100,50, pics, links, texts);
}
function InsertImageViewer(flashURL, targetObj, focus_width, focus_height, text_height, imageList, linkList, titleList)
{
var swf_height = focus_height + text_height;
var divObj = document.getElementById(targetObj);
divObj.innerHTML =
'<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 + '">'
+ '<param name="allowScriptaccess" value="sameDomain">'
+ '<param name="wmode" value="transparent">'
+ '<param name="movie" value="' + flashURL + '">'
+ '<param name="quality" value="high">'
+ '<param name="bgcolor" value=#ffffff>'
+ '<param name="menu" value="false">'
+ '<param name=wmode value="opaque">'
+ '<param name="FlashVars" value="'
+ 'pics=' + imageList
+ '&links=' + linkList
+ '&texts=' + titleList
+ '&borderwidth=' + focus_width
+ '&borderheight=' + focus_height
+ '&textheight=' + text_height + '">'
+ '<embed src="'+ flashURL +'" wmode="opaque" FlashVars="'
+ 'pics=' + imageList
+ '&links=' + linkList
+ '&texts=' + titleList
+ '&borderwidth=' + focus_width
+ '&borderheight=' + focus_height
+ '&textheight=' + text_height
+ '" menu="false" bgcolor=#ffffff quality="high" '
+ 'width="' + focus_width
+ '" height="' + swf_height
+ '" allowScriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
+ '</object>';
}
</script>
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public string pics = "''";
public string links = "''";
public string texts = "''";
protected void Page_Load(object sender, EventArgs e)
{
pics = "'1/1.jpg'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
links = "'Img.aspx'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
texts = "'标题'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
}
}
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public string pics = "''";
public string links = "''";
public string texts = "''";
protected void Page_Load(object sender, EventArgs e)
{
pics = "'1/1.jpg'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
links = "'Img.aspx'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
texts = "'标题'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
}
}
浙公网安备 33010602011771号