前台 aspx
<
script
type
="text/javascript"
src
="../Js/sinaflash.js"
></
script
>
< table width ="370" border ="0" cellpadding ="0" cellspacing ="0" class ="line11" >
< tr >
< td height ="290" align ="center" >
<!-- 循环图片 -->
< div id ="flashcontent1" style ="width:360" ></ div >
< script type ="text/javascript" >
var sinaFlash1 = new sinaFlash( " ../Uploads/UserHousePics/EstatePic/Rotates/BasicFlash/nhpicture.swf " , " demo " , " 360 " , " 260 " , " 8 " , " #ffffff " );
sinaFlash1.addParam( " quality " , " best " );
sinaFlash1.addParam( " wmode " , " transparent " );
// 此处添图片信息等内容,用“|”分割,用“#”分割的部分分别代表图片地址,左侧按钮标题文字,左侧按钮消息文字,大图片的大标题文字,大图片的消息文字,大图片的连接地址!focusmovie.swf
sinaFlash1.addVariable( " mypic " , " <%=ShowPicString %> " );
sinaFlash1.write( " flashcontent1 " );
</ script >
<!-- 循环图片结束 -->
</ td >
</ tr >
</ table >
< table width ="370" border ="0" cellpadding ="0" cellspacing ="0" class ="line11" >
< tr >
< td height ="290" align ="center" >
<!-- 循环图片 -->
< div id ="flashcontent1" style ="width:360" ></ div >
< script type ="text/javascript" >
var sinaFlash1 = new sinaFlash( " ../Uploads/UserHousePics/EstatePic/Rotates/BasicFlash/nhpicture.swf " , " demo " , " 360 " , " 260 " , " 8 " , " #ffffff " );
sinaFlash1.addParam( " quality " , " best " );
sinaFlash1.addParam( " wmode " , " transparent " );
// 此处添图片信息等内容,用“|”分割,用“#”分割的部分分别代表图片地址,左侧按钮标题文字,左侧按钮消息文字,大图片的大标题文字,大图片的消息文字,大图片的连接地址!focusmovie.swf
sinaFlash1.addVariable( " mypic " , " <%=ShowPicString %> " );
sinaFlash1.write( " flashcontent1 " );
</ script >
<!-- 循环图片结束 -->
</ td >
</ tr >
</ table >
后台:
public
string ShowPicString =
"";
public void ReadRotatePics( int HID)
{
string sql = " select PID,bPic,yPath,mPath,Dpath,picmemo from EstatePhoto where EID = ' " + HID + " ' and PicCategory = '外景图' ";
DataSet ds = NewCommmonDb.CommonDataSet(sql);
if (ds.Tables[ 0].Rows.Count > 0)
{
string picName = ""; // 原图
string yPath = ""; // 年
string mPath = ""; // 月
string dPath = ""; // 日
string picMemo = ""; // 说明
string picLink = " RotatePicDetail.aspx?id= ";
for ( int i = 0; i < ds.Tables[ 0].Rows.Count; i++)
{
picid = ds.Tables[ 0].Rows[i][ 0].ToString(); // PID
picName = ds.Tables[ 0].Rows[i][ 1].ToString(); // 原图
yPath = ds.Tables[ 0].Rows[i][ 2].ToString(); // 年
mPath = ds.Tables[ 0].Rows[i][ 3].ToString(); // 月
dPath = ds.Tables[ 0].Rows[i][ 4].ToString(); // 日
picMemo = ds.Tables[ 0].Rows[i][ 5].ToString(); // 说明
ShowPicString += " ../Uploads/UserHousePics/EstatePic/Rotates/RotatePics/NewHousePics/ " + yPath + " / " + mPath + " / " + dPath + " / " + picName + " # " + picMemo + " # " + picLink + picid + " | ";
}
ShowPicString = ShowPicString.TrimEnd( ' | ');
}
else
{
ShowPicString = " ../Uploads/UserHousePics/EstatePic/Rotates/RotatePics/NewHousePics/001.jpg#暂无图## ";
}
}
public void ReadRotatePics( int HID)
{
string sql = " select PID,bPic,yPath,mPath,Dpath,picmemo from EstatePhoto where EID = ' " + HID + " ' and PicCategory = '外景图' ";
DataSet ds = NewCommmonDb.CommonDataSet(sql);
if (ds.Tables[ 0].Rows.Count > 0)
{
string picName = ""; // 原图
string yPath = ""; // 年
string mPath = ""; // 月
string dPath = ""; // 日
string picMemo = ""; // 说明
string picLink = " RotatePicDetail.aspx?id= ";
for ( int i = 0; i < ds.Tables[ 0].Rows.Count; i++)
{
picid = ds.Tables[ 0].Rows[i][ 0].ToString(); // PID
picName = ds.Tables[ 0].Rows[i][ 1].ToString(); // 原图
yPath = ds.Tables[ 0].Rows[i][ 2].ToString(); // 年
mPath = ds.Tables[ 0].Rows[i][ 3].ToString(); // 月
dPath = ds.Tables[ 0].Rows[i][ 4].ToString(); // 日
picMemo = ds.Tables[ 0].Rows[i][ 5].ToString(); // 说明
ShowPicString += " ../Uploads/UserHousePics/EstatePic/Rotates/RotatePics/NewHousePics/ " + yPath + " / " + mPath + " / " + dPath + " / " + picName + " # " + picMemo + " # " + picLink + picid + " | ";
}
ShowPicString = ShowPicString.TrimEnd( ' | ');
}
else
{
ShowPicString = " ../Uploads/UserHousePics/EstatePic/Rotates/RotatePics/NewHousePics/001.jpg#暂无图## ";
}
}
Js/sinaflash.js 下载 /Files/tiger8000/sinaflash.js.txt
/*
*
* @author [sina]zhangping1@
* @version v1.1.3
* Date:2006-9-8 2006-12-15
*/
if( typeof(sina)!="object"){ var sina={};}
sina.$= function(objId){ if(!objId){ throw new Error("sina.$(String objId)参数必须")}
if(document.getElementById){ return eval('document.getElementById("'+objId+'")')} else if(document.layers){ return eval("document.layers['"+objId+"']")} else{ return eval('document.all.'+objId)}}
sinaFlash= function(C,v,x,V,c,X,i,O,I,l,o){ var z= this; if(!document.createElement||!document.getElementById){ return}
z.id=v?v:"";z.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";z.codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+(c?c:"7")+",0,0,0";z.width=x;z.height=V;z.movie=C;z.bgcolor=X?X: null;z.quality=O?O:"high";z.src=z.movie;z.pluginspage="http://www.macromedia.com/go/getflashplayer";z.type="application/x-shockwave-flash";z.useExpressInstall=i?i: null;z.xir=(I)?I:window.location;z.redirectUrl=l?l: null;z.detectKey=o?o: null;z.escapeIs= false;z.objAttrs={};z.params={};z.flashVars=[];z.flashVarsStr="";z.embedAttrs={};z.forSetAttribute("id",z.id);z.objAttrs["classid"]=z.classid;z.forSetAttribute("codebase",z.codebase);z.forSetAttribute("width",z.width);z.forSetAttribute("height",z.height);z.forSetAttribute("movie",z.movie);z.forSetAttribute("quality",z.quality);z.forSetAttribute("pluginspage",z.pluginspage);z.forSetAttribute("type",z.type);z.forSetAttribute("bgcolor",z.bgcolor)}
sinaFlash.prototype={getFlashHtml: function(){ var I= this,i='<object '; for( var l in I.objAttrs){i+=l+'="'+I.objAttrs[l]+'" '}
i+='>'; for( var l in I.params){i+='<param name="'+l+'" value="'+I.params[l]+'" /> '}
if(I.flashVarsStr!=""){i+='<param name="FlashVars" value="'+I.flashVarsStr+'" /> '}
i+='<embed '; for( var l in I.embedAttrs){i+=l+'="'+I.embedAttrs[l]+'" '}
i+=' ></embed></object>'; return i},forSetAttribute: function(I,i){ var l= this;I=I.toLowerCase(); switch(I){ case "classid": break; case "pluginspage":l.embedAttrs["pluginspage"]=i; break; case "src":l.embedAttrs["src"]=i;l.params["movie"]=i; break; case "movie":l.params["movie"]=i;l.embedAttrs["src"]=i; break; case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick": case "ondblClick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp": case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove": case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload": case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete": case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll": case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate": case "type":l.embedAttrs["type"]=i; break; case "codebase":l.objAttrs["codebase"]=i; break; case "width":l.objAttrs["width"]=i;l.embedAttrs["width"]=i; break; case "height":l.objAttrs["height"]=i;l.embedAttrs["height"]=i; break; case "align":l.objAttrs["align"]=i;l.embedAttrs["align"]=i; break; case "vspace":l.objAttrs["vspace"]=i;l.embedAttrs["vspace"]=i; break; case "hspace":l.objAttrs["hspace"]=i;l.embedAttrs["hspace"]=i; break; case "class":l.objAttrs["class"]=i;l.embedAttrs["class"]=i; break; case "title":l.objAttrs["title"]=i; break; case "accesskey":l.objAttrs["accesskey"]=i; break; case "name":l.objAttrs["name"]=i;l.embedAttrs["name"]=i; break; case "id":l.objAttrs["id"]=i;l.embedAttrs["name"]=i; break; case "tabindex":l.objAttrs["tabindex"]=i; break; default:l.params[I]=l.embedAttrs[I]=i}},forGetAttribute: function(i){ var I= this;i=i.toLowerCase(); if(I.objAttrs[i]!=undefined){ return I.objAttrs[i]} else if(I.embedAttrs[i]!=undefined){ return I.embedAttrs[i]} else if(I.embedAttrs!=undefined){ return I.embedAttrs[i]} else{ return null}},setAttribute: function(I,i){ this.forSetAttribute(I,i)},getAttribute: function(i){ return this.forGetAttribute(i)},addVariable: function(I,i){ var l= this; if(l.escapeIs){I=escape(I);i=escape(i)}
if(l.flashVarsStr==""){l.flashVarsStr=I+"="+i} else{l.flashVarsStr+="&"+I+"="+i}
l.embedAttrs["FlashVars"]=l.flashVarsStr},getVariable: function(I){ var o= this,i=o.flashVarsStr; if(o.escapeIs){I=escape(I)}
var l= new RegExp(I+"=([^\\&]*)(\\&?)","i").exec(i); if(o.escapeIs){ return unescape(RegExp.$1)}
return RegExp.$1},addParam: function(I,i){ this.forSetAttribute(I,i)},getParam: function(){ return this.forGetAttribute(name)},write: function(i){ var I= this; if( typeof i=="string"){sina.$(i).innerHTML=I.getFlashHtml();} else if( typeof i=="object"){i.innerHTML=I.getFlashHtml();}}}
* @author [sina]zhangping1@
* @version v1.1.3
* Date:2006-9-8 2006-12-15
*/
if( typeof(sina)!="object"){ var sina={};}
sina.$= function(objId){ if(!objId){ throw new Error("sina.$(String objId)参数必须")}
if(document.getElementById){ return eval('document.getElementById("'+objId+'")')} else if(document.layers){ return eval("document.layers['"+objId+"']")} else{ return eval('document.all.'+objId)}}
sinaFlash= function(C,v,x,V,c,X,i,O,I,l,o){ var z= this; if(!document.createElement||!document.getElementById){ return}
z.id=v?v:"";z.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";z.codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+(c?c:"7")+",0,0,0";z.width=x;z.height=V;z.movie=C;z.bgcolor=X?X: null;z.quality=O?O:"high";z.src=z.movie;z.pluginspage="http://www.macromedia.com/go/getflashplayer";z.type="application/x-shockwave-flash";z.useExpressInstall=i?i: null;z.xir=(I)?I:window.location;z.redirectUrl=l?l: null;z.detectKey=o?o: null;z.escapeIs= false;z.objAttrs={};z.params={};z.flashVars=[];z.flashVarsStr="";z.embedAttrs={};z.forSetAttribute("id",z.id);z.objAttrs["classid"]=z.classid;z.forSetAttribute("codebase",z.codebase);z.forSetAttribute("width",z.width);z.forSetAttribute("height",z.height);z.forSetAttribute("movie",z.movie);z.forSetAttribute("quality",z.quality);z.forSetAttribute("pluginspage",z.pluginspage);z.forSetAttribute("type",z.type);z.forSetAttribute("bgcolor",z.bgcolor)}
sinaFlash.prototype={getFlashHtml: function(){ var I= this,i='<object '; for( var l in I.objAttrs){i+=l+'="'+I.objAttrs[l]+'" '}
i+='>'; for( var l in I.params){i+='<param name="'+l+'" value="'+I.params[l]+'" /> '}
if(I.flashVarsStr!=""){i+='<param name="FlashVars" value="'+I.flashVarsStr+'" /> '}
i+='<embed '; for( var l in I.embedAttrs){i+=l+'="'+I.embedAttrs[l]+'" '}
i+=' ></embed></object>'; return i},forSetAttribute: function(I,i){ var l= this;I=I.toLowerCase(); switch(I){ case "classid": break; case "pluginspage":l.embedAttrs["pluginspage"]=i; break; case "src":l.embedAttrs["src"]=i;l.params["movie"]=i; break; case "movie":l.params["movie"]=i;l.embedAttrs["src"]=i; break; case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick": case "ondblClick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp": case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove": case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload": case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete": case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll": case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate": case "type":l.embedAttrs["type"]=i; break; case "codebase":l.objAttrs["codebase"]=i; break; case "width":l.objAttrs["width"]=i;l.embedAttrs["width"]=i; break; case "height":l.objAttrs["height"]=i;l.embedAttrs["height"]=i; break; case "align":l.objAttrs["align"]=i;l.embedAttrs["align"]=i; break; case "vspace":l.objAttrs["vspace"]=i;l.embedAttrs["vspace"]=i; break; case "hspace":l.objAttrs["hspace"]=i;l.embedAttrs["hspace"]=i; break; case "class":l.objAttrs["class"]=i;l.embedAttrs["class"]=i; break; case "title":l.objAttrs["title"]=i; break; case "accesskey":l.objAttrs["accesskey"]=i; break; case "name":l.objAttrs["name"]=i;l.embedAttrs["name"]=i; break; case "id":l.objAttrs["id"]=i;l.embedAttrs["name"]=i; break; case "tabindex":l.objAttrs["tabindex"]=i; break; default:l.params[I]=l.embedAttrs[I]=i}},forGetAttribute: function(i){ var I= this;i=i.toLowerCase(); if(I.objAttrs[i]!=undefined){ return I.objAttrs[i]} else if(I.embedAttrs[i]!=undefined){ return I.embedAttrs[i]} else if(I.embedAttrs!=undefined){ return I.embedAttrs[i]} else{ return null}},setAttribute: function(I,i){ this.forSetAttribute(I,i)},getAttribute: function(i){ return this.forGetAttribute(i)},addVariable: function(I,i){ var l= this; if(l.escapeIs){I=escape(I);i=escape(i)}
if(l.flashVarsStr==""){l.flashVarsStr=I+"="+i} else{l.flashVarsStr+="&"+I+"="+i}
l.embedAttrs["FlashVars"]=l.flashVarsStr},getVariable: function(I){ var o= this,i=o.flashVarsStr; if(o.escapeIs){I=escape(I)}
var l= new RegExp(I+"=([^\\&]*)(\\&?)","i").exec(i); if(o.escapeIs){ return unescape(RegExp.$1)}
return RegExp.$1},addParam: function(I,i){ this.forSetAttribute(I,i)},getParam: function(){ return this.forGetAttribute(name)},write: function(i){ var I= this; if( typeof i=="string"){sina.$(i).innerHTML=I.getFlashHtml();} else if( typeof i=="object"){i.innerHTML=I.getFlashHtml();}}}
---
结束
注意事项:
sinaflash.js 文件 有时候会出现 'sinaflash' 未定义的错误,这种情况是这样的:
用vs.net2008 打开 sinaflash.js 文件 ,然后,另存为---“保存”旁边有一个向下的小箭头,选 “编码保存”,然后,选择 “UTF-8” ,保存即可。
本文介绍了一种利用sinaflash.js在网页中实现图片轮播的方法。通过前后端结合的方式,实现了从数据库读取图片路径,并将图片显示在页面上的功能。文章详细展示了具体的代码实现。
3930

被折叠的 条评论
为什么被折叠?



