让浏览器状态栏动起来

王朝other·作者佚名  2008-05-20
窄屏简体版  字體: |||超大  

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

要实现这样的特效并不是很难,下面就介绍几种这种特效的应用实例:

一、眨眼式

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

<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>

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航