让浏览器状态栏动起来


每当用浏览器一打开别人的主页时,在浏览器的状态栏上就会出现各种形式的文本提示,而且提示是动态的,提示的内容有的是介绍主页内容的,有的是欢迎的信息等等,这样的提示既不影响浏览主页的速度,又不影响观看主页,因为它不占据页面的部分,所以很多的主页都应用这种特效。
要实现这样的特效并不是很难,下面就介绍几种这种特效的应用实例:

一、眨眼式
当浏览器打开网页时,下面的状态栏就会像眨眼睛似地出现文本提示信息(提示的内容可以改成你所需要的任意内容)。
<script language=″JavaScript″>
!--
var yourwords =″欢迎光临阳光馨园(http://mrdu.yeah.net)″;
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://mrdu.yeah.net)!″;
// 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>

上面是几个简单的特效实例,你自己可以设计出更多这样的特效形式,修改成你自己的特殊风格。怎么样?赶紧在你的主页里动手试试吧

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3