js 動(dòng)態(tài)文字滾動(dòng)的例子
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>這是一個(gè)動(dòng)態(tài)JavaScript文字顯示的例子</title>
<script type="text/JavaScript">
var POSITION = 50;
var DELAY = 150;
var MESSAGE = "這是一個(gè)動(dòng)態(tài)JavaScript文字顯示的例子";
function bannerObject(){
this.msg = MESSAGE;
this.out = " ";
this.pos = POSITION;
this.delay = DELAY;
this.i = 0;
this.reset = clearMessage;
}
function clearMessage(){
this.pos = POSITION;
}
var scroll = new bannerObject();
function scroller(){
scroll.out += " ";
if(scroll.pos>0)
for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++){
scroll.out +=" " ;
}
if (scroll.pos>= 0)
scroll.out += scroll.msg;
else
scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length);
document.noticeForm.notice.value = scroll.out;
scroll.out = " ";
scroll.pos--;
scroll.pos--;
if (scroll.pos < -(scroll.msg.length)) {
scroll.reset();
}
window.setTimeout("scroller()", scroll.delay);
}
</script>
</head>
<body onload="scroller()" bgcolor="#000000" link="#C0C0C0" vlink="#C0C0C0" alink="#008080" text="#C0C0C0">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td width="100%">
<form name="noticeForm" action="">
<p><input type="text" name="notice" size="50" style="background-color: rgb(192,192,192)"/></p>
</form>
</td></tr>
</table>
</body>
</html>
在狀態(tài)欄滾動(dòng)文字
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>這是一個(gè)跑馬燈效果的JavaScript文檔-在狀態(tài)欄</title>
<script type="text/JavaScript">
var msg = "這是一個(gè)跑馬燈效果的JavaScript文檔";
var interval = 100;
var spacelen = 120;
var space10 = " ";
var seq = 0;
function Scroll() {
len = msg.length;
window.status = msg.substring(0, seq + 1);
seq++;
if (seq >= len) {
seq = spacelen;
window.setTimeout("Scroll2();", interval);
}
else
window.setTimeout("Scroll();", interval);
}
function Scroll2() {
var out = "";
for (i = 1; i <= spacelen / space10.length; i++)
out +=space10;
out = out + msg;
len = out.length;
window.status = out.substring(seq, len);
seq++;
if (seq >= len) { seq = 0; };
window.setTimeout("Scroll2();", interval);
}
Scroll();
</script>
</head>
<body>
</body>
</html>
相關(guān)文章
Bootstrap菜單按鈕及導(dǎo)航實(shí)例解析
這篇文章主要介紹了Bootstrap菜單按鈕及導(dǎo)航的相關(guān)資料,本文介紹的非常詳細(xì),具有參考借鑒價(jià)值,感興趣的朋友一起學(xué)習(xí)吧2016-09-09解決微信授權(quán)成功后點(diǎn)擊按返回鍵出現(xiàn)空白頁(yè)和報(bào)錯(cuò)的問(wèn)題
這篇文章主要介紹了解決微信授權(quán)成功后點(diǎn)擊按返回鍵出現(xiàn)空白頁(yè)和報(bào)錯(cuò)的問(wèn)題,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06中高級(jí)前端必須了解的JS中的內(nèi)存管理(推薦)
這篇文章主要介紹了中高級(jí)前端必須了解的JS中的內(nèi)存管理,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07禁止iframe頁(yè)面的所有js腳本如alert及彈出窗口等
一個(gè)頁(yè)面里面需要放一個(gè)iframe框架來(lái)預(yù)覽網(wǎng)站,可是被預(yù)覽的這個(gè)網(wǎng)站中含有很多js腳本,于是想禁止iframe里面的腳本,下面是方法2014-09-09添加一個(gè)以前寫(xiě)的table的spliter給大家
添加一個(gè)以前寫(xiě)的table的spliter給大家...2007-01-01js獲取元素到可視區(qū)的距離、瀏覽器窗口滾動(dòng)距離及元素距離瀏覽器頂部距離
這篇文章主要給大家介紹了關(guān)于js獲取元素到可視區(qū)的距離、瀏覽器窗口滾動(dòng)距離及元素距離瀏覽器頂部距離的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-11-11JavaScript中async與await實(shí)現(xiàn)原理與細(xì)節(jié)
這篇文章主要介紹了JavaScript中async與await實(shí)現(xiàn)原理與細(xì)節(jié),文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09詳解js location.href和window.open的幾種用法和區(qū)別
這篇文章主要介紹了詳解js location.href和window.open的幾種用法和區(qū)別,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12