孟子前辈,高手们近来看看JS调用DATALIST里面DIV的问题
JS 代码
<script>
marqueesHeight=100;//滚动区域高度设定
stopscroll=false;
icefable1.scrollTop=1;
with(icefable1){
style.width=0;
style.height=marqueesHeight;
style.overflowX= "visible ";
style.overflowY= "hidden ";
noWrap=true;
onmouseover=new Function( "stopscroll=true ");
onmouseout=new Function( "stopscroll=false ");
}
preTop=0; currentTop=0; stoptime=0;
function init_srolltext(){
icefable2.innerHTML= " ";
icefable2.innerHTML+=icefable1.innerHTML;
icefable1.innerHTML=icefable2.innerHTML+icefable2.innerHTML;
setInterval( "scrollUp() ",1);
}
function scrollUp(){
if(stopscroll==true) return;
currentTop+=1;
if(currentTop==101)//向上滚动高度设定
{
stoptime+=1;
currentTop-=1;
if(stoptime==200)//停顿时间设定
{
currentTop=0;
stoptime=0;
}
}
else {
preTop=icefable1.scrollTop;
icefable1.scrollTop+=1;
if(preTop==icefable1.scrollTop){
icefable1.scrollTop=icefable2.offsetHeight-marqueesHeight;
icefable1.scrollTop+=1;
}
}
}
init_srolltext();
</script>
ASP.NET
<asp:datalist id= "dltImg " runat= "server " RepeatColumns= "5 "> <ItemTemplate>
<div id= "icefable1 " style= "width:700; position:absolute; z-index:2; left: 190px; top: 90px; "> <TABLE id= "Table4 " height= "130 " cellSpacing= "1 " cellPadding= "0 " width= "140 " border= "0 "> <TR> <TD> 帮定内容 <TD> </TR>
</TABLE>
</div>
<div id= "icefable2 " style= "position:absolute;z-index:1;visibility:hidden "> </div> </ItemTemplate>
我想实现 -行多列 滚动循环翻滚
[解决办法]
不是高手,不看
[解决办法]
你的icefable2在客户端有多了,只能唯一啊。
必须采取一种方法避免,如使用ItemIndex进行标识等
[解决办法]
见教了。
[解决办法]
<%@ Page language= "c# " Codebehind= "WebForm2.aspx.cs " AutoEventWireup= "false " Inherits= "WebApplication3.WebForm2 " %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN " >
<HTML>
<HEAD>
<title> WebForm2 </title>
<meta content= "Microsoft Visual Studio .NET 7.1 " name= "GENERATOR ">
<meta content= "C# " name= "CODE_LANGUAGE ">
<meta content= "JavaScript " name= "vs_defaultClientScript ">
<meta content= "http://schemas.microsoft.com/intellisense/ie5 " name= "vs_targetSchema ">
<SCRIPT>
marqueesHeight=100;//滚动区域高度设定
stopscroll=false;
function onlod()
{
debugger
var icefable1=document.getElementById( "icefable1 ");
icefable1.scrollTop=1;
with(icefable1){
style.width=0;
style.height=marqueesHeight;
style.overflowX= "visible ";
style.overflowY= "hidden ";
noWrap=true;
onmouseover=new Function( "stopscroll=true ");
onmouseout=new Function( "stopscroll=false ");
}
}
preTop=0; currentTop=0; stoptime=0;
function init_srolltext(){
var icefable1=document.getElementById( "icefable1 ");
var icefable2=document.getElementById( "icefable2 ");
icefable2.innerHTML= " ";
icefable2.innerHTML+=icefable1.innerHTML;
icefable1.innerHTML=icefable2.innerHTML+icefable2.innerHTML;
setInterval( "scrollUp() ",1);
}
function scrollUp(){
var icefable1=document.getElementById( "icefable1 ");
var icefable2=document.getElementById( "icefable2 ");
if(stopscroll==true) return;
currentTop+=1;
if(currentTop==100)//向上滚动高度设定
{
stoptime+=1;
currentTop-=1;
if(stoptime==200)//停顿时间设定
{
currentTop=0;
stoptime=0;
}
}
else {
preTop=icefable1.scrollTop;
icefable1.scrollTop+=1;
if(preTop==icefable1.scrollTop){
icefable1.scrollTop=icefable2.offsetHeight-marqueesHeight;
icefable1.scrollTop+=1;
}
}
}
</SCRIPT>
</HEAD>
<body onload= "onlod();init_srolltext(); " MS_POSITIONING= "GridLayout ">
<form id= "Form1 " method= "post " runat= "server ">
<DIV id= "icefable1 "> <asp:datalist id= "dltImg " runat= "server " RepeatColumns= "2 " Width= "100px " Height= "8px " RepeatDirection= "Horizontal ">
<ItemTemplate>
<TABLE height= "100 " cellSpacing= "0 " cellPadding= "0 " width= "100 " border= "0 ">
<TR>
<TD bgColor= "red "> <%# DataBinder.Eval(Container.DataItem, "djsj ")%> </TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:datalist> </DIV>
<DIV id= "icefable2 " style= "Z-INDEX: 1; VISIBILITY: hidden; POSITION: absolute "> </DIV>
<FONT face= "宋体 "> </FONT> <FONT face= "宋体 "> </FONT>
</form>
</body>
</HTML>
后台数据绑定自己写