熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Javascript >> 正文

網頁狀態欄特效全攻略

2022-06-13   來源: Javascript 

  在上網時我們注意往往是網站頁面內容而狀態欄不會被人太多注意如果我們給頁面的狀態欄加一些特效肯定會使你的網站增添一道風景下面就給大家介紹種常見的狀態欄特效的Javascript代碼

  特效一滾動顯示

  第一步:把如下代碼加入<head>區域中

<script language=Javascript>
<!
function scrollit(seed) {
var m = HI你 好! ;
var m = 歡迎訪問賽迪 ;
var m = 請多提意見謝 謝! ;
var m = 歡迎您下次再來! ;
var m = ;
var msg=m+m+m+m+m;
var out = ;
var c = ;
if (seed > ) {
seed;
cmd=scrollit(+seed+);
timerTwo=windowsetTimeout(cmd);
}
else if (seed <= && seed > ) {
for (c= ; c < seed ; c++) {
out+= ;
}
out+=msg;
seed;
windowstatus=out;
cmd=scrollit(+seed+);
timerTwo=windowsetTimeout(cmd);
}
else if (seed <= ) {
if (seed < msglength) {
out+=msgsubstring(seedmsglength);
seed;
windowstatus=out;
cmd=scrollit(+seed+);
timerTwo=windowsetTimeout(cmd);
}
else {
windowstatus= ;
timerTwo=windowsetTimeout(scrollit());
}
}
}
//>
</script>

  第二步:把如下代碼加入<body>區域中

<body background=baggif onLoad=scrollit()>

  特效二文字從狀態欄的右邊循環彈出

  把如下代碼加入<head>區域中

<script language=Javascript>
var MESSAGE = 歡迎來到賽迪網請多提意見謝謝!
var POSITION =
var DELAY =
var scroll = new statusMessageObject()
function statusMessageObject(pd) {
thismsg = MESSAGE
thisout =
thispos = POSITION
thisdelay = DELAY
thisi =
thisreset = clearmessage}
function clearmessage() {
thispos = POSITION}
function scroller() {
for (scrolli = ; scrolli < scrollpos; scrolli++) {
scrollout += }
if (scrollpos >= )
scrollout += scrollmsg
else scrollout = scrollmsgsubstring(scrollposscrollmsglength)
windowstatus = scrollout
scrollout =
scrollpos
if (scrollpos < (scrollmsglength)) {
scrollreset()}
setTimeout (scroller()scrolldelay)}
function snapIn(jumpSpacesposition) {
var msg = scrollmsg
var out =
for (var i=; i<position; i++)
{out += msgcharAt(i)}
for (i=;i<jumpSpaces;i++)
{out += }
out += msgcharAt(position)
windowstatus = out
if (jumpSpaces <= ) {
position++
if (msgcharAt(position) == )
{position++ }
jumpSpaces = position
} else if (jumpSpaces > )
{jumpSpaces *= }
else
{jumpSpaces}
if (position != msglength) {
var cmd = snapIn( + jumpSpaces + + position + );
scrollID = windowsetTimeout(cmdscrolldelay);
} else { windowstatus=
jumpSpaces=
position=
cmd = snapIn( + jumpSpaces + + position + );
scrollID = windowsetTimeout(cmdscrolldelay);
return false }
return true}
snapIn();
</script>

  特效三title彈出效果

  把如下代碼加入<head>區域中

  <script language=javascript>
<! Hide me
var index_count = ;
var title_string = 歡迎光臨賽迪網()這裡有許多電腦應用方面的文章
是您學習電腦的好去處!希望您能夠常來! ;
var title_length = title_stringlength;
var cmon;
var kill_length = ;
function loopTheScroll()
{
scrollTheTitle();
if(kill_length > title_length)
{
clearTimeout(cmon);
}

  kill_length++;
cmon = setTimeout(loopTheScroll();)
}

  function scrollTheTitle()
{
var doc_title = title_stringsubstring((title_length index_count )title_length);
documenttitle = doc_title;

  index_count++;
}
loopTheScroll();
//>
</script>

  特效四文字組合彈出

  第一步:把如下代碼加入<head>區域中

  <script language=javascript>
<! Hide this script from old browsers
var speed =
var pause =
var timerID = null
var bannerRunning = false
var ar = new Array()

  ar[] = 歡迎來到賽迪網!
ar[] = 它是您學校電腦的好幫手!
ar[] = 請多提意見謝謝!

  var message =
var state =
clearState()
function stopBanner() {
if (bannerRunning)
clearTimeout(timerID)
bannerRunning = false
}

  function startBanner() {
stopBanner()
showBanner()
}
function clearState() {
state =
for (var i = ; i < ar[message]length; ++i) {
state +=
}
}
function showBanner() {
if (getString()) {
message++
if (arlength <= message)
message =
clearState()
timerID = setTimeout(showBanner() pause)
bannerRunning = true
} else {
var str =
for (var j = ; j < statelength; ++j) {
str += (statecharAt(j) == ) ? ar[message]charAt(j) :
}
windowstatus = str
timerID = setTimeout(showBanner() speed)
bannerRunning = true
}
}
function getString() {
var full = true
for (var j = ; j < statelength; ++j) {
if (statecharAt(j) == )
full = false
}
if (full)
return true
while () {
var num = getRandom(ar[message]length)
if (statecharAt(num) == )
break
}
state = statesubstring( num) + + statesubstring(num + statelength)
return false
}
function getRandom(max) {
return Mathround((max ) * Mathrandom())
}
// End Hiding Here >
</script>

  第二步:把如下代碼加入<body>區域中

<body bgcolor=#fefd onLoad=startBanner()>

  特效五文字不停閃爍

  第一步:把如下代碼加入<head>區域中

<script language=>
<!
var yourwords = 歡迎光臨賽迪網()!!!;
var speed = ;
var control = ;
function flash()
{
if (control == )
{
windowstatus=yourwords;
control=;
}
else
{
windowstatus=;
control=;
}
setTimeout(flash()speed);
}
// >
</script>

  第二步:把如下代碼加入<body>區域中

<body bgcolor=#fefd onLoad=flash()>

  特效六文字來回出現

  第一步:把如下代碼加入<head>區域中

<script LANGUAGE=Javascript>
<! Begin
var Message=歡迎光臨賽迪網()!!!!!;
var place=;
function scrollIn() {
windowstatus=Messagesubstring( place);
if (place >= Messagelength) {
place=;
windowsetTimeout(scrollOut());
} else {
place++;
windowsetTimeout(scrollIn());
}
}
function scrollOut() {
windowstatus=Messagesubstring(place Messagelength);
if (place >= Messagelength) {
place=;
windowsetTimeout(scrollIn() );
} else {
place++;
windowsetTimeout(scrollOut() );
}
}
// End >
</script>

  第二步:把<body>中的內容改為:

<body bgcolor=#fefd onLoad=scrollIn()>

  特效七狀態欄固定信息

<body bgcolor=#fefd onmouseover=selfstatus=歡迎光臨賽迪網;return true>
From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/25297.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.