javascript| scrolling Text
* * This program is based on a version of 21CN improvement.
* The original idea is to build a table in a layer of only one row, and then use the
* ScrollTop of the table to achieve progressive scrolling. But this method can only operate in IE, can not scroll in Mozzila.
* Improved use of IFrame to replace the original layer, using the body of the scrolltop to achieve scrolling.
* Btw:dannykang is my English name.
*/
FILE:scrolltext.js Created:dannykang @ 2004-5-19
var Stopscroll=false;
var pretop=0;
var newtop=0;
var currenttop=0;
var stoptime=0;
var iinterval;
function Init_srolltext () {
Document.body.scrolltop=0;
Document.body.onmouseover = new Function ("Stopscroll=true");
Document.body.onmouseout = new Function ("Stopscroll=false");
Document.body.oncontextmenu = new Function ("return false;");
Document.body.onselectstart = new Function ("return false;");
Iinterval = SetInterval ("Scrollup ()", 25);
}
function Scrollup () {
if (stopscroll==true) return;
Currenttop+=1; Scroll 1 pixels at a time
if (currenttop==24) {//(23 per row) after scrolling through one line
Stoptime+=1; 1 Units of time (25 milliseconds)
Currenttop-=1; The number of scrolling displacements restores the original value
if (stoptime==100) {///pause time accumulates 100 units of time, recalculate rolling displacement and pause time
Currenttop=0;
stoptime=0;
if (Confirm ("One line end ... \n\nok to stop, Cancel to go on.")) {clearinterval (iinterval);}
}
}else{
Document.body.scrollTop = Pretop +1; Scrolling 1 pixels
if (pretop< document.body.scrollTop) {
Pretop = Document.body.scrollTop;
}
else {//if scrolling to the end (scrolling is not rolling)
Pretop = 1
Document.body.scrollTop = 1;
if (Confirm ("Scroll to all text ending .....) ["+pretop+"/"+document.body.scrolltop+"] \n\nok to stop, Cancel to go on. ") {clearinterval (iinterval);}
}
}
}
Init_srolltext (); Start
/* Call the IFRAME of the page
<iframe id= "adtxt1" align= "center" style= "width:590"; Height:23 "src=" index_js/adtxt1.htm "name=" iframe1 "frameborder=" 0 "scrolling=" no "></iframe>
/* Scrolling Content HTML page adtxt1.htm source code * *
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML><HEAD><TITLE> Rolling News </TITLE>
<meta http-equiv=content-type content= "text/html; charset=gb2312 ">
<style type=text/css>
BODY,TD {
Font-size:9pt
}
</STYLE>
<body scroll=no leftmargin= "0" topmargin= "0" marginwidth= "0" marginheight= "0" >
<table border=0 align= "center" cellpadding=0 cellspacing=0>
<tr>
<TD height=23 align= "center" nowrap><a href= "http://photo.zsnet.com/tounament/" target= "_blank" > Zhongshan " A moment of good life "digital photography competition </a>
<a href= "http://www.zsyjedu.net.cn/jianjie.htm" target= "_blank" ><font color= "#FF0000" > China Business Technician Association Professional Qualification Certification Training </font></a>
</td>
</tr>
<!--headline: same content as-->
<tr>
<TD height=23 align= "center" nowrap><a href= "http://wh3351.zsnet.com/news/news_view.asp?news_id=5670" target= "_blank" > "Good Mountain Good water good children" Zhongshan cultural celebrity promotion month </a>
<a href= "http://news.zsnet.com/newscontent.asp?newsid=77777" target= "_blank" > Zhongshan Labor and Social Security work Bulletin </a> </td>
</tr>
<!--tr>
<TD height=23 align= "center" nowrap> </td>
</tr-->
<!--tail: Same content as headline-->
<tr>
<TD height=23 align= "center" nowrap> <a href= "http://photo.zsnet.com/tounament/" target= "_blank" > Zhongshan " A moment of good life "digital photography competition </a>
<a href= "http://www.zsyjedu.net.cn/jianjie.htm" target= "_blank" ><font color= "#FF0000" > China Business Technician Association Professional Qualification Certification Training </font></a>
</td>
</tr>
</table>
<!--the last line in the body-->
<script language=javascript src= "Scrolltext.js" ></SCRIPT>
</BODY>
</HTML>
/* Call page Demo effect see:http://www.zhongshan.gd.cn * *