首页 > 编程知识 正文

新闻滚动js代码(web滚动代码)

时间:2023-12-19 16:21:18 阅读:317892 作者:RSKM

本文目录一览:

js如何实现新闻轮播

加入有5张图片,第一张css 样式是display:block 那其余4张图片就是display:none对吧,然后js获取li元素下标(一般都是li哈),利用定时任务,比如说每隔5秒就换图片,那就是当前下标的li 样式是display:block,其他都是display:none,就这样循环

我想要一种新闻滚动的效果,用js实现的

可以上斑马谷看看,图片轮显和网页图片特效,可以调整大小更改文字

js循环倒计时代码 每5秒循环倒计时到0 再从5秒开始 到0之后刷新页面 类似网易的滚动新闻

html

head

title JS时间循环/title

script type="text/javascript"

window.onload = function(){

showTime(1);

}

var seconds = 5;

function showTime(time)

{

document.getElementById("time_div").innerHTML = seconds;

if(seconds = 0)

{

seconds--;

}

else{

seconds = 5;

window.location.reload();

}

setTimeout("showTime()",1000);

}

/script

/head

body

div id="time_div"/div

/body

/html

PHP,想实现滚动新闻效果。

滚动可以用html代码marquee/marquee实现。

可点击新闻用a href=""/a,要在新窗口打开的话targer参数要用blank,

至于新闻在数据库中,那数据库中应该有id,标题,日期,内容等字段吧。

读取数据库,显示标题,新闻内容要重新写一个页面,把id作为参数传递过去,就很轻松了。示例下:

marqueea href="新闻页面连接.php?id=?=$id?" target="blank"?=$biaoti?/a/marquee

要显示多条的话可以用循环。思路这样肯定没错。具体代码要你自己完成了。

求帮忙改一段简单的网页代码!

SCRIPT language=JAVAscript

// ------ 定义全局变量

var theNewsNum;

var theAddNum;

var totalNum;

var CurrentPosion=0;

var theCurrentNews;

var theCurrentLength;

var theNewsText;

var theTargetLink;

var theCharacterTimeout;

var theNewsTimeout;

var theBrowserVersion;

var theWidgetOne;

var theWidgetTwo;

var theSpaceFiller;

var theLeadString;

var theNewsState;

function startTicker(){

// ------ 设置初始数值

theCharacterTimeout = 50;//字符间隔时间

theNewsTimeout = 2000;//新闻间隔时间

theWidgetOne = "_";//新闻前面下标符1

theWidgetTwo = "-";//新闻前面下标符

theNewsState = 1;

theNewsNum = document.getElementById("incoming").children.AllNews.children.length;//新闻总条数

theAddNum = document.getElementById("incoming").children.AddNews.children.length;//补充条数

totalNum =theNewsNum+theAddNum;

theCurrentNews = 0;

theCurrentLength = 0;

theLeadString = " ";

theSpaceFiller = " ";

runTheTicker();

}

// --- 基础函数

function runTheTicker(){

if(theNewsState == 1){

if(CurrentPosiontheNewsNum){

setupNextNews();

}

else{

setupAddNews();

}

CurrentPosion++;

if(CurrentPosion=totalNum||CurrentPosion=1){

CurrentPosion=0;//最多条数不超过num_gun条

}

}

if(theCurrentLength != theNewsText.length){

drawNews();

}

else{

closeOutNews();

}

}

// --- 跳转下一条新闻

function setupNextNews(){

theNewsState = 0;

theCurrentNews = theCurrentNews % theNewsNum;

theNewsText = document.getElementById("AllNews").children[theCurrentNews].children.Summary.innerText;

theTargetLink = document.getElementById("AllNews").children[theCurrentNews].children.Summary.children[0].href;

theCurrentLength = 0;

document.all.hottext.href = theTargetLink;

theCurrentNews++;

}//欢迎来到站长特效网,我们的网址是,很好记,zz站长,js就是js特效,本站收集大量高质量js代码,还有许多广告代码下载。

function setupAddNews() {

theNewsState = 0;

theCurrentNews = theCurrentNews % theAddNum;

theNewsText = document.getElementById("AllNews").children[theCurrentNews].children.Summary.innerText;

theTargetLink = document.getElementById("AllNews").children[theCurrentNews].children.Summary.children[0].href;

theCurrentLength = 0;

document.all.hottext.href = theTargetLink;

theCurrentNews++;

}

// --- 滚动新闻

function drawNews(){

var myWidget;

if((theCurrentLength % 2) == 1){

myWidget = theWidgetOne;

}

else{

myWidget = theWidgetTwo;

}

document.all.hottext.innerHTML = theLeadString + theNewsText.substring(0,theCurrentLength) + myWidget + theSpaceFiller;

theCurrentLength++;

setTimeout("runTheTicker()", theCharacterTimeout);

}//欢迎来到站长特效网,我们的网址是,很好记,zz站长,js就是js特效,本站收集大量高质量js代码,还有许多广告代码下载。

// --- 结束新闻循环

function closeOutNews(){

document.all.hottext.innerHTML = theLeadString + theNewsText + theSpaceFiller;

theNewsState = 1;

setTimeout("runTheTicker()", theNewsTimeout);

}

window.onload=startTicker;

/SCRIPT

a href="#ZC_BLOG_HOST#"站长特效网/a,站长必备的高质量网页特效和广告代码。zzjs.net,站长js特效。hr

!--欢迎来到站长特效网,我们网站收集大量高质量js特效,提供许多广告代码下载,网址:,zzjs@msn.com,用.net打造靓站--

a href="" id="hottext"/a

div id=incoming style="DISPLAY: none;float:left"

div id=AllNews

div id=0

div id="Summary" style="border:1px solid red"

a href="" target="_blank"fontbsky提示您:这个效果不错吧~_~/b/font/a

a href="" target="_blank"font color="red"b欢迎来到站长特效网/b/font/a /div

div id=NewsLink /div

/div

/div

div id=AddNews height="25"/div

/div

114行和115行是显示的内容。。。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。