刚从CS转到BS,很多东西不懂,大家多多帮忙现在很多网站主页都有一个flash样式的广告,右下角有1、2、3、4、、、的选项,如果鼠标不点就每个几秒换一个图片显示,就像新华网http://www.xinhuanet.cn/主页中的那个flash广告请问是如何做的????是否可以动态生成??那位老大给个例子看看,多谢!!
解决方案 »
- 等待您的回答:运行ASP.NET页面 应用程序脱机
- 怎么写死循环程序
- .net 2.0 linq 使用LinqBridge 出现功能“扩展方法”无法使用,因为它不是iso-2 C# 语言规范的一部分
- asp.net页面 PageLoad事件之前获得到当前屏幕高宽
- sohighthesky mngzilin wuyq11 ojlovecd sorry 是我把文件删除了,补300分,之一
- 怎么样实现,页面的多语言功能呢?
- 上传asp.net网站数据库连接字符串怎么设置?
- 这样的枚举类型如何获得?
- 刚开始用ASP.NET,帮我解决个问题,谢谢!
- Webservice发布问题
- 有关excel操作的错误
- 请教一段关于asp.net的代码
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="fuwuxiangmu.ascx.cs" Inherits="Include_fuwuxiangmu" %>
<table width="228">
<tr>
<td style="font-family: verdana, tahoma, sans-serif;FONT-SIZE: 12px;font-weight:bold;background-color: #F4F4F4;">+ 服务项目</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="208" height="214">
<tr>
<td><asp:Literal ID="Literal1" runat="server"></asp:Literal></td>
</tr>
</table>后台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.Collections.Generic;public partial class Include_fuwuxiangmu : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindList();
}
}
void BindList()
{
List<Models.ServerProject> list = BLL.ServerProject.SelectMethod1();
String str = @"<a href=""javascript:goUrl()"">
<span class=""f14b"">
<script type=""text/javascript"">
imgUrl1=""$img1$"";
imgtext1=""$text1$""
imgLink1=escape(""$url1$"");
imgUrl2=""$img2$"";
imgtext2=""$text2$""
imgLink2=escape(""$url2$"");
imgUrl3=""$img3$"";
imgtext3=""$text3$""
imgLink3=escape(""$url3$"");
var focus_width=218
var focus_height=200
var text_height=14
var swf_height = focus_height+text_height
var pics=imgUrl1+""|""+imgUrl2+""|""+imgUrl3
var links=imgLink1+""|""+imgLink2+""|""+imgLink3
var texts=imgtext1+""|""+imgtext2+""|""+imgtext3
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=""swf/focus.swf""><param name=""quality"" value=""high""><param name=""bgcolor"" value=""#FFFFFF"">');
document.write('<param name=""menu"" value=""false""><param name=wmode value=""opaque"">');
document.write('<param name=""FlashVars"" value=""pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"">');
document.write('<embed src=""swf/pixviewer.swf"" wmode=""opaque"" FlashVars=""pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"" menu=""false"" bgcolor=""#FFFFFF"" quality=""high"" width=""'+ focus_width +'"" height=""'+ focus_height +'"" allowScriptAccess=""sameDomain"" type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" />'); document.write('</object>');
</script>
</span></a><span id=""focustext"" class=""f14b""></span>"; for (int i = 1; i <= list.Count; i++)
{ str = str.Replace("$img" + i + "$", list[i-1].ImgUrl.ToString()).Replace("$text" + i + "$", list[i-1].Title.ToString()).Replace("$url" + i + "$", "/fuwuxiangmu.aspx");
}
this.Literal1.Text = str;
}
}
用JavaScript实现你的效果就很好,看看: <script type="text/javascript">
var id=-1;
function openpictures(pictureid)
{var showpicture=document.getElementById("showpicture");
if(pictureid==0)
{
showpicture.src="images/pic1.jpg";
}
if(pictureid==1)
{
showpicture.src="images/pic2.jpg";
}
}
function autoshowpicture()
{
var showpicture=document.getElementById("showpicture");
id++;
if(id==0)
{
showpicture.src="images/pic1.jpg";
}
if(id==1)
{
showpicture.src="images/pic2.jpg";
id=-1;
}
setInterval("autoshowpicture()", 3000)
}
</script>
<body onload="autoshowpicture()">
<form id="form1" runat="server">
<div>
<a href="javascript:openpictures(0)">Picture one</a>
<a href="javascript:openpictures(1)">Picture two</a>
</div>
<div >
<img src="images/wed.jpg" alt="no picture show!" id="showpicture" />
</div>
</form>
</body>
<div >
<img src="images/pic1.jpg" alt="no picture show!" id="showpicture" />
</div>
把图片的路径都换成你自己的
要把setInterval("autoshowpicture()", 3000);
放在函数的外面,然后把body的onload去掉,才好。
后面的分号有没有效果都一样啊,晕。