一、眨眼式 当浏览器打开网页时,下面的状态栏就会像眨眼睛似地出现文本提示信息(提示的内容可以改成你所需要的任意内容)。 <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>