急寻滚动新闻代码。谢谢。最好注明要改动的地方。

liuyuting 2002-04-23 10:10:06
现在要做一个滚动新闻,非常着急,明天早上八点之前就要。可是从别的网上下载的不好用(最多只能实现一条新闻的滚动)。希望哪位大拿指点迷津,让我明天有条生路,谢谢了。分数当然望大的给了。只要代码有效就给,绝不食言。谢谢。
...全文
838 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyuting 2002-05-16
  • 打赏
  • 举报
回复
呵呵,谢谢老兄,我好长时间没来这里了,其实,这个问题后来我解决了,具体怎么解决的让我来告诉你吧.也许你的代码很好用,呵呵,因为我使用Fronpage去编辑的,所以总出错,如果用dreamware去编辑的话就会很好用了.也许这就是问题所在吧.
davidoff 2002-04-23
  • 打赏
  • 举报
回复
另外,关于这类的代码,网上到处都是,犯不着来这儿。
davidoff 2002-04-23
  • 打赏
  • 举报
回复
哪个啊?我两个都试过才给你发上来的,没有错误啊。你是不是复制少了什么?
liuyuting 2002-04-23
  • 打赏
  • 举报
回复
谢谢davidoff老兄的及时留言,但是,经过我的实际操作,发现一个问题,就是不能正常运行,总会出现一个提示说什么“出现运行期错误。是否纠正该错误?行:24。错误:未结束的字符串常量。”请指点迷津,谢谢。
yzflying 2002-04-23
  • 打赏
  • 举报
回复

<SCRIPT language=JavaScript>
<!--//
var version = "other"
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

if (browserName == "Netscape" && browserVer >= 3) version = "n3";
else if (browserName == "Netscape" && browserVer < 3) version = "n2";
else if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) version = "e4";
else if (browserName == "Microsoft Internet Explorer" && browserVer < 4) version = "e3";

function stopError()
{
return true;
}
window.onerror = stopError;

function wireOpen()
{
if (version == "e4")
{
document.write("<marquee behavior=scroll direction=up width=100% height=150 scrollamount=1 scrolldelay=70 onmouseover='this.stop()' onmouseout='this.start()'>")
}
}

function wireClose()
{
if (version == "e4")
{
document.write("</marquee>")
}
}
//-->
</SCRIPT>

以上代码放在<head>和</head>之间

以下代码放在要滚动的地方
<script language=JavaScript>
wireOpen();
</script>
这里放滚动的具体内容
<script language=JavaScript>
wireClose();
</script>

davidoff 2002-04-23
  • 打赏
  • 举报
回复
还有一个:

将以下代码直接插入<body>和</body>之间

scrollerwidth是滚动区域的宽度
scrollerheight是滚动区域的高度
scrollerbgcolor是滚动区域的背景色
messages[0]...是滚动的内容,大家可以根据自己的需要来改动


<script language="JavaScript1.2">

//configure the below five variables to change the style of the scroller
var scrollerwidth=150
var scrollerheight=200
var scrollerbgcolor='#F4F5E7'
//set below to '' if you don't wish to use a background image
var scrollerbackground=''

//configure the below variable to change the contents of the scroller
var messages=new Array()
messages[0]="<font face='Arial'>
<a href='http://www.csdn.net'>欢迎光临
程序员大本营!!</a></font>"
messages[1]="<font face='Arial'><a href='http://
www.blueidea.com'>
Blueidea.com - 蓝色经典 国内少有的网页设计,
艺术集会点,有不少高手哦~</a></font>"
messages[2]="<font face='Arial'><a href='http://www.macromedia.com/
ResearchTriangle/Facility/4490'>Macromedia.com 你是在用Dreamweaver和Flash吗?
那为什么不去它们的老家看看?</a></font>"
messages[3]="<font face='Arial'><a href='http://www.microsoft.com'>Microsoft.com
虽然经常被人骂,但是里
面的确有一些值得学习的东西</a></font>"
messages[4]="<font face='Arial'><a href='http://www.msdn.com/link.htm'>MSDN.com
Microsoft开的技术站,
是不少人研究的对象</a></font>"

//////////////以下内容如果你不懂,不要动!///////////////////////

if (messages.length>1)
i=2
else
i=0

function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.top>0&&tlayer.top<=5){
tlayer.top=0
setTimeout("move1(tlayer)",3000)
setTimeout("move2(document.main.document.second)",3000)
return
}
if (tlayer.top>=tlayer.document.height*-1){
tlayer.top-=5
setTimeout("move1(tlayer)",100)
}
else{
tlayer.top=scrollerheight
tlayer.document.write(messages[i])
tlayer.document.close()
if (i==messages.length-1)
i=0
else
i++
}
}

function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.top>0&&tlayer2.top<=5){
tlayer2.top=0
setTimeout("move2(tlayer2)",3000)
setTimeout("move1(document.main.document.first)",3000)
return
}
if (tlayer2.top>=tlayer2.document.height*-1){
tlayer2.top-=5
setTimeout("move2(tlayer2)",100)
}
else{
tlayer2.top=scrollerheight
tlayer2.document.write(messages[i])
tlayer2.document.close()
if (i==messages.length-1)
i=0
else
i++
}
}

function move3(whichdiv){
tdiv=eval(whichdiv)
if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){
tdiv.style.pixelTop=0
setTimeout("move3(tdiv)",3000)
setTimeout("move4(second2)",3000)
return
}
if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){
tdiv.style.pixelTop-=5
setTimeout("move3(tdiv)",100)
}
else{
tdiv.style.pixelTop=scrollerheight
tdiv.innerHTML=messages[i]
if (i==messages.length-1)
i=0
else
i++
}
}

function move4(whichdiv){
tdiv2=eval(whichdiv)
if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){
tdiv2.style.pixelTop=0
setTimeout("move4(tdiv2)",3000)
setTimeout("move3(first2)",3000)
return
}
if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){
tdiv2.style.pixelTop-=5
setTimeout("move4(second2)",100)
}
else{
tdiv2.style.pixelTop=scrollerheight
tdiv2.innerHTML=messages[i]
if (i==messages.length-1)
i=0
else
i++
}
}

function startscroll(){
if (document.all){
move3(first2)
second2.style.top=scrollerheight
second2.style.visibility='visible'
}
else if (document.layers){
document.main.visibility='show'
move1(document.main.document.first)
document.main.document.second.top=scrollerheight+5
document.main.document.second.visibility='show'
}
}

window.onload=startscroll

</script>
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgcolor=&{scrollerbgcolor}; background=&{scrollerbackground}; visibility=hide>
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0])
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[1])
</script>
</layer>
</ilayer>
<script language="JavaScript1.2">
if (document.all){
document.writeln('<span id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+' ;background-image:url('+scrollerbackground+')">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0">')
document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0;top:1;">')
document.write(messages[0])
document.writeln('</div>')
document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0;top:0;visibility:hidden">')
document.write(messages[1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</span>')
}
</script>
davidoff 2002-04-23
  • 打赏
  • 举报
回复
将以下代码加入<body>和</body>之间:


<script language="JavaScript1.2">



var delay=3000 //set delay between message change (in miliseconds)
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //set opening tag, such as font declarations
fcontent[0]="<b>www.csdn.net</b><br><br>欢迎您光临,感谢您提出宝贵意见<br><br>有意见和问题请在论坛中提出"
fcontent[1]="<b>www.csdn.net</b><br><br>  特效代码为网站设计师和网页爱好者提供专业的特效代码"
fcontent[2]="<b>www.csdn.net</b><br><br>欢迎您光临!
closetag='</font>'

var fwidth=150 //set scroller width
var fheight=150 //set scroller height

///No need to edit below this line/////////////////

var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0

if (DOM2)
faderdelay=2000

//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color="rgb(255,255,255)"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
colorfade()
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.document.write(begintag+fcontent[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.document.close()
}

index++
setTimeout("changecontent()",delay+faderdelay)
}

// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
// Modified by Dynamicdrive.com

frame=20;
hex=255 // Initial color value.

function colorfade() {
// 20 frames fading process
if(frame>0) {
hex-=12; // increase color value
document.getElementById("fscroller").style.color="rgb("+hex+","+hex+","+hex+")"; // Set color value.
frame--;
setTimeout("colorfade()",20);
}
else{
document.getElementById("fscroller").style.color="rgb(0,0,0)";
frame=20;
hex=255
}
}

if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+';padding:2px"></div>')

window.onload=changecontent
</script>


<ilayer id="fscrollerns" width=&{fwidth}; height=&{fheight};><layer id="fscrollerns_sub" width=&{fwidth}; height=&{fheight}; left=0 top=0></layer></ilayer>
liuyuting 2002-04-23
  • 打赏
  • 举报
回复
忘了写上我的邮箱了,liuyuting@263.net。谢谢。
HTML怎么设置自动滚动的图片,转:HTML中让图片滚动标签的使用方法 实例:需要滚动的文字需要滚动的文字也可以程序代码也可以是图片说明:1、中间的内容可以为 文字,图片,也可以是由程序生成的文字或图片2、onMouseOut="this.start()" :用来设置鼠标移出该区域时继续滚动onMouseOver="this.stop()":用来设置鼠标移入该区域时停止滚动属性:align设定标签内容的对齐方式absbottom:绝对底部对齐(与g、p等字母的最下端对...

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧