请大家帮个忙!
是这样:有3条(数量不定)新闻,要求的效果是: 开始时显示第1条新闻,3秒后(或者5秒后)
第1条新闻慢慢淡掉,接着出现第2条新闻,3秒后,第2条新闻也慢慢淡掉,接着出现第3条新闻
...就是这样的效果
不知道大家有没有见过这样的效果呢???
<html><head>
<style type="text/css">
/*Example CSS for the two demo tickers*/
#domticker{
width: 200px;
height: 100px;
border: 1px dashed black;
padding: 5px;
background-color: #FFFFCA;
}
#domticker div{ /*IE6 bug fix when text is bold and fade effect (alpha filter) is enabled. Style inner DIV with same color as outer DIV*/
background-color: #FFFFCA;
}
#domticker a{
font-weight: bold;
}
#domticker2{
width: 350px;
height: 1.2em;
border: 1px solid black;
padding: 3px;
}
#domticker2 a{
text-decoration: none;
}
.someclass{ //class to apply to your scroller(s) if desired
}
</style>
<script type="text/javascript">
/*Example message arrays for the two demo scrollers*/
var tickercontent=new Array()
tickercontent[0]='<b>浣溪沙</b><br />蔌蔌衣巾落枣花,村南村北响缫车。牛衣古柳卖黄瓜。酒困路长惟欲睡,日高人渴漫思茶。敲门试问野人家。'
tickercontent[1]='<b>昭君怨</b><br />谁作桓伊三弄,惊破绿窗幽梦。新月与愁烟,满江天。欲去又还不去,明日落花飞絮。飞絮送行舟,水东流。'
tickercontent[2]='<b>减字木兰花 春月</b><br />春庭月午,摇荡香醪光欲舞。步转回廊,半落梅花婉娩香。轻云薄雾,总是少年行乐处。不似秋光,只与离人照断肠。'
var tickercontent2=new Array()
tickercontent2[0]='<a href="guyer.net.cn'">http://www.guyer.net.cn">guyer.net.cn</a>'
tickercontent2[1]='<a href="http://www.sina.com">新浪: 新闻资询平台</a>'
tickercontent2[2]='<a href="http://www.163.com">网易: 商业门户网站</a>'
</script>
<script type="text/javascript">
function domticker(content, divId, divClass, delay, fadeornot){
this.content=content
this.tickerid=divId //ID of master ticker div. Message is contained inside first child of ticker div
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
this.pointer=1
this.opacitystring=(typeof fadeornot!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : ""
if (this.opacitystring!="") this.delay+=500 //add 1/2 sec to account for fade effect, if enabled
this.opacitysetting=0.2 //Opacity value when reset. Internal use.
document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">'+content[0]+'</div></div>')
var instanceOfTicker=this
setTimeout(function(){instanceOfTicker.initialize()}, delay)
}
domticker.prototype.initialize=function(){
var instanceOfTicker=this
this.contentdiv=document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages
document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
this.rotatemsg()
}
domticker.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
this.contentdiv.innerHTML=this.content[this.pointer]
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.content.length-1)? this.pointer+1 : 0
setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container
}
}
// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------
domticker.prototype.fadetransition=function(fadetype, timerid){
var contentdiv=this.contentdiv
if (fadetype=="reset")
this.opacitysetting=0.2
if (contentdiv.filters && contentdiv.filters[0]){
if (typeof contentdiv.filters[0].opacity=="number") //IE6+
contentdiv.filters[0].opacity=this.opacitysetting*100
else //IE 5.5
contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
}
else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){
contentdiv.style.MozOpacity=this.opacitysetting
}
else
this.opacitysetting=1
if (fadetype=="up")
this.opacitysetting+=0.2
if (fadetype=="up" && this.opacitysetting>=1)
clearInterval(this[timerid])
}
</script></head>
<body><script type="text/javascript">
//new domticker(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds, optionalfadeswitch)
new domticker(tickercontent, "domticker", "someclass", 3000, "fadeit")
document.write("<br />")
new domticker(tickercontent2, "domticker2", "someclass", 3000)
</script>
</body></html>
<html><head>
<style type="text/css">
#tic {
/* enter any styles for the ticker below */
border: .05em #CEC3AD solid;
font-size:0.85em;
padding:10px;
width:400px;
line-height:20px;
}
#tic * {
/* this will hide all children tags */
font-size: 1em;
margin:0px;
padding:0px;
display:none;
}
#tic a {
/* add more tags to this list if you wish to display them inside the children */
display:inline;
}
</style>
<script type="text/javascript">
//more javascript from http://www.smallrain.net
var list; // global list variable cache
var tickerObj; // global tickerObj cache
var hex = 255;
function fadeText(divId) {
if(tickerObj)
{
if(hex>0) {
hex-=5; // increase color darkness
tickerObj.style.color="rgb("+hex+","+hex+","+hex+")";
setTimeout("fadeText('" + divId + "')", fadeSpeed);
} else
hex=255; //reset hex value
}
}
function initialiseList(divId) {
tickerObj = document.getElementById(divId);
if(!tickerObj)
reportError("Could not find a div element with id \"" + divId + "\"");
list = tickerObj.childNodes;
if(list.length <= 0)
reportError("The div element \"" + divId + "\" does not have any children");
for (var i=0; i<list.length; i++) {
var node = list[i];
if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
tickerObj.removeChild(node);
}
run(divId, 0);
}
function run(divId, count) {
fadeText(divId);
list[count].style.display = "block";
if(count > 0)
list[count-1].style.display = "none";
else
list[list.length-1].style.display = "none";
count++;
if(count == list.length)
count = 0;
window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000);
}
function reportError(error) {
alert("The script could not run because you have errors:\n\n" + error);
return false;
}
var interval = 7; // interval in seconds
var fadeSpeed = 40; // fade speed, the lower the speed the faster the fade. 40 is normal.
</script></head>
<body><div id="tic">
<h1>什么是ASP?</h1>
<p>
Active Server Pages(ASP,活动服务器页面)就是一个编程环境,在其中,可以混合使用HTML、脚本语言以及组件来创
建服务器端功能强大的Internet应用程序。 </p>
<p>
如果你以前创建过一个站点,其中混合了HTML、脚本语言以及组件,你就可以在其中加入ASP程序代码。通过在HTML页面中加入脚本命令,你
可以创建一个HTML用户界面,并且,还可以通过使用组件包含一些商业逻辑规则。</p>
<p>
组件可以被脚本程序调用,也可以由其他的组件调用。
</p>
<h2>什么是 ASP.NET?</h2>
<p>
ASP.NET 是建立在公共语言运行库上的编程框架,可用于在服务器上生成功能强大的 Web 应用程序。</p>
<p>
与以前的 Web 开发模型相比,ASP.NET 提供了数个重要的优点:增强的性能、世界级的工具支持、威力和灵活性、简易性、可管理性、可缩放
性和可用性、自定义性和扩展性、安全性。
</p>
<h2>什么是PHP?</h2>
<p>
PHP 是一种用来制作动态网页的服务器端脚本语言。你通过PHP和HTML创建页面。当访问者打开网页时,服务器端便会处理 PHP 指令,然后把
其处理结果送到访问者的浏览器上面,就好像 ASP 或者是 ColdFusion 一样。然而,PHP 跟 ASP 或 ColdFusion 不一样的地方在于,它是跨
平台的开放源代码。
</p>
</div>
<script type="text/javascript">
<!--
initialiseList("tic");
//-->
</script>
</body></html>