一、眨眼式 當瀏覽器開啟網頁時,下面的狀態列就會像眨眼睛似地出現文本提示資訊(提示的內容可以改成你所需要的任意內容)。
<script language=″JavaScript″>
!--
var yourwords =″歡迎光臨網頁教學網(http://www.webjx.com)″;
var speed = 1000;
var control = 1;
function flash()
{
if (control == 1)
{
window.status=yourwords;
control=0;
}
else
{
window.status=″ ″;
control=1;
}
setTimeout(″flash();″,speed);
}
flash();
</script>
二、冒泡式 當瀏覽器開啟網頁時,下面的文本就像是冒泡一樣,一個字一個字地出現,提示資訊同樣可以改變成你自己的內容。
把下面的代碼放到首頁中的<body>和</body>之間即可
<script language=″JavaScript″>
<!--
var msg =″歡迎光臨網頁教學網″;
var interval =300
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 = 0;
window.status = ′ ′;
window.setTimeout(″Scroll();″, interval );
}
else
window.setTimeout(″Scroll();″, interval );
}
Scroll();
</script>
三、標題列出現 當瀏覽器開啟網頁時,上面的標題列就會移動出現一行提示資訊,提示資訊可隨你改變。
把下面的代碼放到首頁中的<body>和</body>之間即可
<script language=″JavaScript″>
<!--Hide me
file://″index_count″ is subtracted from ″title_length″ to get the first # of the substring method
var index_count = 0;
// What you want to scroll in the title bar
var title_string =″歡迎光臨網頁教學網(http://www.webjx.com)!″;
// length of title string
var title_length = title_string.length;
// Variable for setTimeout()
var cmon;
// Counter for clearTimeout()
var kill_length = 0;
function loopTheScroll()
{
scrollTheTitle();
// If greater than length of string then stop calling itself
if(kill_length 〉 title_length)
{
clearTimeout(cmon);
}
kill_length++;
// Calls itself 10x per second - change the value to speed up or slow down the scroll (in 1/1000th of a second)
cmon = setTimeout(″loopTheScroll();″,100)
}
function scrollTheTitle()
{
// Difficult to explain, must be familiar w/ the substring method
var doc_title = title_string.substring((title_length - index_count - 1),title_length);
// put doc_title in the title bar
document.title = doc_title;
index_count++;
}
loopTheScroll();
file://--〉
</script>