上一页       3     4     5     6            下一页

 

文字特效代码6

 

Thu

26

Feb

2009

180、各种形式文字输出

180、各种形式文字输出

脚本说明:

第一步:把如下代码加入<body>区域中

<script language=javascript>

 

       //Change the following 4 messages to your liking.

 

       var txt = "欢迎你的光临"

       var txt2 = "I love javascript"

       var txt3 = "记得要经常来呀"

       var txt4 = "谢谢你的光临"

 

       //Make sure that "def" is longer than your longest message

 

       var def = "_______________________________________" 

 

       //Don't change any of the following

 

       var end = txt4.length

       var end2 = end / 2

       var close = end2

       var close2 = end2

       var close3 = end

       var max2 = txt3.length

       var mid = max2 / 2

       var max = txt2.length

       var msg

       var msg2

       var msg3

       var msg4

       var msg5

       var msg6

       var word = 0

       var word2 = txt.length

       var scroll = 0

       var door = max

       var blink = 0

       var blink2 = 20

       var stay = 0

       var timestay

       var time

       var time2

       var doortime

       var timeblink

       var timescroll

       var timeblink2

       var timeclose

 

function Type() {

       if (word <= txt.length) { word++;

       msg = txt.substring(0, word);

       document.form1.text.value = msg

       time = setTimeout("Type()", 100) }

       else { word = 0;

       clearTimeout(time);

       Stay() }

}

 

function Stay() {

       if (stay==0) { document.form1.text.value = txt;

       stay = 1;

       timestay = setTimeout("Stay()", 1000) }

       else if (stay==1) { document.form1.text.value = txt;

       stay = 0;

       clearTimeout(timestay);

       Erase() }

}

 

function Close() {

       if(close2 <= end) {

       close -= 1;

       close2++;

       close3 -= 2;

       msg6 = txt4.substring(close, end2) + def.substring(0, close3) + txt4.substring(end2, close2);

       document.form1.text.value = msg6;

       timeclose = setTimeout("Close()", 100)

       }

       else { clearTimeout(timeclose);

       close = end2;

       close2 = end2;

       close3 = end;

       Stay2()}

}

 

function Stay2() {

       if (stay==0) { document.form1.text.value = txt4;

       stay = 1;

       timestay = setTimeout("Stay2()", 1300) }

       else if (stay==1) { document.form1.text.value = txt4;

       stay = 0;

       clearTimeout(timestay);

       Doors() }

}

 

function Erase() {

       if (word2 <= txt.length && word2 > 0) { word2 -= 1;

       msg2 = txt.substring(0, word2)

       document.form1.text.value = msg2

       time2 = setTimeout("Erase()", 20)}

       else  { word2 = txt.length;

       clearTimeout(time2);

       Close() }

      

}

 

function Doors() {

       if (door >= 0) {

       door -= 1;

       msg3 = txt2.substring(door, max)

       document.form1.text.value = msg3

       doortime = setTimeout("Doors()", 100)

       }

       else { door = max;

       clearTimeout(doortime);

       Blink() }

}

 

function Blink() {

       if (blink==0) { document.form1.text.value = txt2;

       blink = 1;

       timeblink = setTimeout("Blink()", 200) }

       else if (blink==1) { document.form1.text.value = "";

       blink = 2 ;

       timeblink = setTimeout("Blink()", 200) }

       else if (blink==2) { document.form1.text.value = txt2;

       blink = 3;

       timeblink = setTimeout("Blink()", 200) }

       else if (blink==3) { document.form1.text.value = "";

       blink = 4;

       timeblink = setTimeout("Blink()", 200) }

       else if (blink==4) { document.form1.text.value = txt2;

       blink = 5;

       timeblink = setTimeout("Blink()", 200) }

       else if (blink==5) { document.form1.text.value = "";

       blink = 0;

       clearTimeout(timeblink);

       Scroll() }

}

 

 

function Scroll() {

       if(scroll <= txt2.length) { msg4 = txt2.substring(scroll, txt2.length);

       document.form1.text.value = msg4;

       scroll++;

       timescroll = setTimeout("Scroll()", 100)

       }

       else { clearTimeout(timescroll);

       scroll = 0

       Blink2() }

      

}

 

function Blink2() {

       if (blink2==20) { msg5 = txt3;

       document.form1.text.value = msg5;

       blink2 = 0;

       timeblink2 = setTimeout("Blink2()", 800) }

       else if (blink2==0) { msg5 = txt3.substring(0, mid) + def.substring(0, mid);

       document.form1.text.value = msg5;

       blink2 = 1;

       timeblink2 = setTimeout("Blink2()", 300) }

       else if (blink2==1) { msg5 = def.substring(0, mid) + txt3.substring(mid, max2);

       document.form1.text.value = msg5;

       blink2 = 2 ;

       timeblink2 = setTimeout("Blink2()", 300) }

       else if (blink2==2) { msg5 = txt3.substring(0, mid) + def.substring(0, mid);

       document.form1.text.value = msg5;

       blink2 = 3;

       timeblink2 = setTimeout("Blink2()", 300) }

       else if (blink2==3) { msg5 = def.substring(0, mid) + txt3.substring(mid, max2);

       document.form1.text.value =msg5;

       blink2 = 4;

       timeblink2 = setTimeout("Blink2()", 300) }

       else if (blink2==4) { msg5 = txt3.substring(0, mid) + def.substring(0, mid);

       document.form1.text.value = msg5;

       blink2 = 5;

       timeblink2 = setTimeout("Blink2()", 300) }

       else if (blink2==5) { msg5 = def.substring(0, mid) + txt3.substring(mid, max2);

       document.form1.text.value = msg5;

       blink2 = 6;

       timeblink2 = setTimeout("Blink2()", 300) }

       else if (blink2==6) { document.form1.text.value = txt3;

       blink2 = 20;

       clearTimeout(timeblink2);

       Type() }

}

 

 

</script>

<form name=form1><input type=text name=text size=32,0></form>

 

第二步:把如下代码加入<body>区域中

<body bgcolor="#fef4d9" onload="Type()">

 

0 Comments

Thu

26

Feb

2009

179、自由控制文字输入

179、自由控制文字输入

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT>

 

 

<!--  Activate Cloaking Device

 

 

 

 

// used to track position in message

 

 

   var i = 0;

 

 

// used to cycle thru messages                                          

 

 

   var TextNumber = 0;

 

 

// array of messages                       

 

 

   var TextInput = new Object();

 

 

// used to load manipulate message         

 

 

   var HelpText="";                             

 

 

// used to load message

 

 

   var Text = ""; 

 

 

// length of timeout (smaller is faster)                                 

 

 

   var Speed=50;

 

 

// added to end of each message to create a pause

 

 

   var WaitSpace="                "

 

 

// used to position text in ver 2.0

 

 

   var addPadding="\r\n";

 

 

 

 

 

// Each element of TextInput represents a single message.

 

 

TextInput[0] = "This is just another method of displaying information to your visitors."; 

 

 

TextInput[1] = "The routine is based on the T-Banner by Tomer and Yehuda Shiran.";

 

 

TextInput[2] = "I've selected the TextArea for display to utilize the wrap-around feature.";

 

 

TextInput[3] = "The messages can be made to cycle manually, check out Tele-Type 1 in Tim's Lab.";

 

 

TextInput[4] = "Though this scheme is not perfect, you have to admit it is different!";

 

 

TextInput[5] = "I've learned that you can reduce flicker by shortening the messages.";

 

 

TextInput[6] = "One may want to add speed adjustment to better match individual machines.";

 

 

TextInput[7] = "Whether practical or not, at least it was fun developing Timothy's Tele-Type Display!";

 

 

TotalTextInput = 7; // (0, 1, 2, 3, 4, 5, 6, 7)

 

 

 

 

 

// Positioning and speed vary between versions.

 

 

var Version =  navigator.appVersion; 

 

 

if (Version.substring(0, 1)==3)

 

 

   {

 

 

   Speed=200;

 

 

   addPadding="";

 

 

   }

 

 

 

 

 

for (var addPause = 0; addPause <= TotalTextInput; addPause++)

 

 

   {TextInput[addPause]=addPadding+TextInput[addPause]+WaitSpace;}

 

 

 

 

 

var TimerId

 

 

var TimerSet=false;

 

 

 

 

 

// Called by the Start button.

 

 

function startMessage()

 

 

   {

 

 

   if (!TimerSet)

 

 

      {

 

 

      TimerSet=true;

 

 

      teletype();

 

 

      }

 

 

   }

 

 

 

 

 

// Gets and displays character from rollMessage() .

 

 

// Variable Speed controls length of timeout and thus the speed of typing.

 

 

function teletype()

 

 

   {

 

 

   Text=rollMessage();

 

 

   TimerId = setTimeout("teletype()", Speed)

 

 

   document.forms[0].elements[0].value=Text;

 

 

   }

 

 

 

 

 

// Pulls one character at a time from string and returns (as Text) to function teletype() for displaying.

 

 

function rollMessage ()

 

 

   {

 

 

   Wait_yn=false;

 

 

   i++;

 

 

   var CheckSpace = HelpText.substring(i-1, i);

 

 

   CheckSpace = "" + CheckSpace;

 

 

   if (CheckSpace == " ")

 

 

      {i++;}

 

 

   if (i >= HelpText.length+1)

 

 

      {

 

 

      i=0;

 

 

      if (TextNumber < TotalTextInput)

 

 

         {TextNumber++;}

 

 

      else {TextNumber = 0;}

 

 

      initMessage();

 

 

      }

 

 

   Text = HelpText.substring(0, i);

 

 

   return (Text);

 

 

   }

 

 

 

 

 

// Called from onLoad in BODY tag & resetDisplay().

 

 

function titleDisplay()

 

 

   {

 

 

   document.forms[0].elements[0].value="\r\n         AutoCycle Tele-Type Display";

 

 

   initMessage();

 

 

   }

 

 

 

 

 

// Sets Text & HelpText equal to messages for use in rollMessage ().

 

 

function initMessage()

 

 

   {

 

 

   Text = TextInput[TextNumber]

 

 

   HelpText = Text;

 

 

   }

 

 

 

 

 

// Called by Stop button.

 

 

function stopMessage()

 

 

   {

 

 

   TimerSet=false;

 

 

   clearTimeout (TimerId);

 

 

   }

 

 

 

 

 

// Called by Reset button.

 

 

function resetDisplay()

 

 

   {

 

 

   TimerSet=false;

 

 

   clearTimeout (TimerId);

 

 

   TextNumber=0;

 

 

   i=0;

 

 

   titleDisplay();  

 

 

   }

 

 

 

 

 

 

 

 

// Deactivate Cloaking -->

 

</SCRIPT>

 

<form>

<TEXTAREA ROWS=2 COLS=55 wrap=yes></TEXTAREA>

<BR>

<TABLE BORDER=0 WIDTH=300>

<TD align="center"><INPUT TYPE="button" VALUE="Start" onClick="startMessage()">

<TD align="center"><INPUT TYPE="button" VALUE="Reset" onClick="resetDisplay()">

<TD align="center"><INPUT TYPE="button" VALUE="Stop" onClick="stopMessage()">

</TABLE>

 

 

 

第二步:把如下代码加入<body>区域中

<body bgcolor="#fef4d9" onLoad="titleDisplay()">

 

0 Comments

Thu

26

Feb

2009

178、逐字出现的信息条

178、逐字出现的信息条

脚本说明:

第一步:把如下代码加入<body>区域中

<script language="JavaScript">

 

 

function makeArray() {

 

                                this.length = makeArray.arguments.length

 

                                for (var i = 0; i < this.length; i++)

 

                                this[i+1] = makeArray.arguments[i]

 

                          }

 

                          var fArray = new makeArray;

 

                          fArray[0]="Message 1 goes here. ";

 

                          fArray[1]="Message 2 goes here.  "

 

                          fArray[2]="Message 3 goes here. "

 

                          fArray[3]="Message 4 goes here. "

 

 

 

                          var x = 1;

 

                          var y = 0;

 

                          var msg1 = fArray[y];

 

 

 

                          function newsFeed() {

 

                             if (x==msg1.length+1) {

 

                                for (var z=0; z < 70000; z++);

 

                                y+=1;

 

                                if (y > 3) y=0;

 

                                document.form1.news2.value=' ';

 

                                msg1 = fArray[y];

 

                                x=0;

 

                             }

 

                             document.form1.news2.value=msg1.substring(0,x); 

 

                             x+=1;

 

                             setTimeout("newsFeed() ",100);

 

                          }

 

 

</script>

<form name="form1">

<textarea wrap=physical rows=10 cols=25 name="news2">

</textarea>

</form>

 

 

 

 

第二步:把如下代码加入<body>区域中

<body bgcolor="#fef4d9" onLoad="newsFeed()">

 

0 Comments

Thu

26

Feb

2009

177、点击改变文字

177、点击改变文字

脚本说明:

把如下代码加入<body>区域中:

<SCRIPT LANGUAGE="JAVASCRIPT">

 

n = (document.layers) ? 1:0

ie = (document.all) ? 1:0

function change_content(divname, newtext) {

    if (n) {

        document.layers[divname].document.write(newtext)

        document.layers[divname].document.close()

    }

    if (ie) document.all[divname].innerHTML = newtext

}

 

</SCRIPT>

<A HREF="#" onClick="change_content('layer1', 'This is the new text!')">Change the current text to "This is the new text!"</A><BR>

<DIV ID="layer1" STYLE="position:absolute; top:100; left:200; visibility:visible">

This is a layer called "layer1"<BR>

</DIV>

 

0 Comments

Thu

26

Feb

2009

176、文字连续闪烁

176、文字连续闪烁

脚本说明:

第一步:把如下代码加入<body>区域中

<script language="JAVASCRIPT">

     colors2 = new Array(6);

     colors2[0]="#000000";

     colors2[1]="#333300";

     colors2[2]="#665500";

     colors2[3]="#997700";

     colors2[4]="#CC9900";

     colors2[5]="#FFCC00";

 

     var i=0;

     function fLi2() {

             line2.style.visibility = "visible";

             if (i<6) {

                     line2.style.color = colors2[i];

                     i++;

                     timerID2 = setTimeout( "fLi2()", 16);

             }

             else {

             i=0;

             line2.style.visibility="hidden";

             TimerID2=setTimeout("fLi2()",1000);

             }

       }

     </script>

 

     <div id=line2 style="container:positioned; position=relative; width=50%; height=10%; left=10%;

      font-family=Arial; font-size=35px; line-height=28px; color=black; visibility=hidden;">

     JavaScript Planet

     </div>

 

 

 

第二步:把如下代码加入<body>区域中

<body bgcolor="#fef4d9" onload="TimerID2=setTimeout('fLi2()',500)" onunload="clearTimeout(TimerID2)">

 

0 Comments

Thu

26

Feb

2009

175、点击出现链接

175、点击出现链接

脚本说明:

把如下代码加入<body>区域中:

 

<center><font color=red face="隶书" size=6>点击出现链接</font></center>

<br>

<center>

<table border=5 bordercolor=blue borderlight=green>

<tr><td align=center><font size=5 color=red face="Arial, Helvetica, sans-serif"><strong>下面框中为脚本显示区</strong></font></td></tr>

<tr><td align=left height=90 width=400>

<div id=Out0 style="position:relative; left:20; top:+15px; width:90%;" >

  <span id=Out1 class=Outline style="hand: hand; "></span><b id=Out1 class=Outline style="cursor: hand; ">点击这里出现链接</b>

  <div id=Out1details style="display:None; position:relative; left:12;">

       <P>

<u><a href=http://www.7stk.com target=_blank>网页特效代码</a></u>

<P>

        <U><a href=http://www.sohu.com target=_blank>搜狐</a></u>

<P>

<u><a href=http://www.sina.com.cn target=_blank>新浪</a></u>

<P>     <U><a href=http://www.yahoo.com target=_blank>雅虎</a></u>

<P>

<u><a href=http://www.263.com target=_blank>北京在线</a></u>

<P>     <U><a href=http://www.7stk.com/fine/ch/c01.htm target=_blank>祝福你,圣诞节快快乐乐、幸幸福福</a></u>

<P>

<u><a href=http://www.7stk.com/fine/ny/n1.htm target=_blank>2008年新年祝福网页</a></u>

<p>

  </div>

</div>

<script language=JavaScript>

 

function clickHandler() {

  var targetId, srcElement, targetElement;

  srcElement = window.event.srcElement;

  if (srcElement.className == "Outline") {

     targetId = srcElement.id + "details";

     targetElement = document.all(targetId);

     if (targetElement.style.display == "none") {

        targetElement.style.display = "";

     } else {

        targetElement.style.display = "none";

     }

  }

}

 

document.onclick = clickHandler;

 

</script>

 

0 Comments

Thu

26

Feb

2009

174、非常漂亮的菜单条

174、非常漂亮的菜单条

脚本说明:

第一步:把如下代码加入<body>区域中:

<STYLE>

.conts  {visibility:hidden}

.tab    {       border-top:solid thin #E0E0E0;

                        border-right:solid thin gray;

                        border-left:solid thin #E0E0E0;

                        font-family:Verdana;

                        font-size:10pt;

                        text-align:center;

                        font-weight:normal}

 

.selTab {       border-left:solid thin white;

                        border-top:solid thin white;

                        border-right:solid thin black;

                        font-weight:bold;

                        text-align:center}

 

</STYLE>

<SCRIPT LANGUAGE=JavaScript>

 

 

//a public function that the container uses to pass in values for the labels

function public_Labels(label1, label2, label3, label4, label5, label6, label7){

       

        t1.innerText = label1;

        t2.innerText = label2;

        t3.innerText = label3;

        t4.innerText = label4;

        t5.innerText = label5;

        t6.innerText = label6;

        t7.innerText = label7;

}

 

//a public function that the container uses to pass in values for the card containers

function public_Contents(contents1, contents2, contents3, contents4, contents5, contents6, contents7){

 

        t1Contents.innerHTML = contents1;

        t2Contents.innerHTML = contents2;

        t3Contents.innerHTML = contents3;

        t4Contents.innerHTML = contents4;

        t5Contents.innerHTML = contents5;

        t6Contents.innerHTML = contents6;

        t7Contents.innerHTML = contents7;

 

        init();

}

 

//sets the default display to tab 1

function init(){

        tabContents.innerHTML = t1Contents.innerHTML;

}       

 

//this is the tab switching function

var currentTab;

var tabBase;

var firstFlag = true;

 

 

function changeTabs(){

 

        if(firstFlag == true){

                currentTab = t1;

                tabBase = t1base;

                firstFlag = false;

        }

 

        if(window.event.srcElement.className == "tab"){

 

                currentTab.className = "tab";

 

                tabBase.style.backgroundColor = "white";

 

                currentTab = window.event.srcElement;

 

                tabBaseID = currentTab.id + "base";

 

                tabContentID = currentTab.id + "Contents";

 

                tabBase = document.all(tabBaseID);

 

                tabContent = document.all(tabContentID);

 

                currentTab.className = "selTab";

                

                tabBase.style.backgroundColor = "";

 

                tabContents.innerHTML = tabContent.innerHTML;

 

        }

}

 

 

</SCRIPT>

 

 

<DIV STYLE="position:absolute; top:40; height:350; width:500; left:25; border:none thin gray">

 

 

<TABLE STYLE="width:100%; height:250" CELLPADDING=0 CELLSPACING=0>

        <TR>

                <TD ID=t1 CLASS=selTab HEIGHT=25>tab 1</TD>

                <TD ID=t2 CLASS=tab>tab 2</TD>

                <TD ID=t3 CLASS=tab>tab 3</TD>

                <TD ID=t4 CLASS=tab>tab 4</TD>

                <TD ID=t5 CLASS=tab>tab 5</TD>

                <TD ID=t6 CLASS=tab>tab 6</TD>

                <TD ID=t7 CLASS=tab>tab 7</TD>

        </TR>

        <TR>

                <TD ID=t1base STYLE="height:2; border-left:solid thin white"></TD>

                <TD ID=t2base STYLE="height:2; background-color:white"></TD>

                <TD ID=t3base STYLE="height:2; background-color:white"></TD>

                <TD ID=t4base STYLE="height:2; background-color:white"></TD>

                <TD ID=t5base STYLE="height:2; background-color:white"></TD>

                <TD ID=t6base STYLE="height:2; background-color:white"></TD>

                <TD ID=t7base STYLE="height:2; background-color:white; border-right:solid thin white"></TD>    

        </TR>

 

 

        <TR>

                <TD HEIGHT="*" COLSPAN=7 ID=tabContents

 

                                                                        STYLE=" border-left:solid thin white;

                                                                                        border-bottom:solid thin white;

                                                                                        border-right:solid thin white">sample contents</TD>

 

        </TR>

</TABLE>

</DIV>

 

 

<DIV CLASS=conts ID=t1Contents>This text is on tab one</DIV>

<DIV CLASS=conts ID=t2Contents>This text is on tab two</DIV>

<DIV CLASS=conts ID=t3Contents>This text is on tab three</DIV>

<DIV CLASS=conts ID=t4Contents>This text is on tab four</DIV>

<DIV CLASS=conts ID=t5Contents>This text is on tab five</DIV>

<DIV CLASS=conts ID=t6Contents>This text is on tab six</DIV>

<DIV CLASS=conts ID=t7Contents>This text is on tab seven</DIV>

 

 

 

 

第二步:<body>中的内容改为:

<body bgcolor="#fef4d9" onload=init() onclick=changeTabs()>

0 Comments

Thu

26

Feb

2009

173、链接在右面打开

173、链接在右面打开

脚本说明:

把如下代码加入<body>区域中:

<SCRIPT>

function _init(){

       for(var i=0;i<document.all.length;i++){

              if(document.all[i].getAttribute("menu")){

                     var attribs = _eat_attrib(document.all[i].getAttribute("menu"));

                     var tree = new Array();

                     var src = document.all.item(attribs["src"]).innerText;  // get the config info from the contents of the designated source element

                     src = _strip(src);     // remove whitespace informatin

                     tree = _compile(tree,src);      // turn it into a multilevel array

 

                     // at this time, associate the element the

                     // menu is attached to with the created menuing elements

                     var menuId = _menus.length;      

                     document.all[i].menuId = menuId;

                     document.all[i].onmouseover = _rootmouseover;

                     document.all[i].onmouseout = _rootmouseout;

 

                     // get and preset designer preferences

                     var attribs = _eat_attrib(document.all[i].getAttribute("menu"));

                     attribs["border-width"] = (attribs["border-width"]!=null?attribs["border-width"]:1);

                     attribs["border-color"] = (attribs["border-color"]!=null?attribs["border-color"]:"black");

                     attribs["background"] = (attribs["background"]!=null?attribs["background"]:"white");

                     attribs["highlight"] = (attribs["highlight"]!=null?attribs["highlight"]:"#DCDCDC");

                     attribs["font-size"] = (attribs["font-size"]!=null?attribs["font-size"]:"normal");

                     attribs["font-family"] = (attribs["font-family"]!=null?attribs["font-family"]:"");

                     attribs["font-color"] = (attribs["font-color"]!=null?attribs["font-color"]:"");

                     attribs["icon-color"] = (attribs["icon-color"]!=null?attribs["icon-color"]:"black");

                     attribs["arrow"] = (attribs["arrow"]!=null?attribs["arrow"]:true);

                     attribs["showrow"] = (attribs["showrow"]!=null?attribs["showrow"]:true);

                     attribs["height"] = (attribs["height"]!=null?attribs["height"]:22);

                     attribs["width"] = (attribs["width"]!=null?attribs["width"]:150);

                     attribs["arrow-offset"] = (attribs["arrow-offset"]!=null?Number(attribs["arrow-offset"]):135);

                     attribs["menu-offset"] = (attribs["menu-offset"]!=null?Number(attribs["menu-offset"]):1);

                     attribs["menu-topoffset"] = (attribs["menu-topoffset"]!=null?Number(attribs["menu-topoffset"]):0);

                     attribs["wait"] = (attribs["wait"]!=null?Number(attribs["wait"]):500);

                     document.all[i].attribs = attribs;

 

                     // now, create all of the needed elements for this menu

                     _create(document.all[i],tree);

              }

       }

}

window.onload = _init;

/////////////////////////

 

 

/////////////////////////

//// takes a position and a string,

//// returns the position of the next unpaired "]" character

function _pair(after,str){

       while(1){

              var nextA = str.indexOf("[",after + 1);

              var nextB = str.indexOf("]",after + 1);

              if(nextA == -1){

                     return nextB;

              }

              if(nextA > nextB){

                     return nextB;

              }

              after = _pair(nextA,str);

       }

}

 

/////////////////////////

//// transforms raw text input into a multilevel array

//// returns an array based on the string input

function _compile(ary,str){

       while(1){ // keep circling and eating the str

 

              // when the str is empty, return the built array

              if(str.length == 0){

                     return ary;

              }

 

              // is there any more sub-arrays?

              var nextA = str.indexOf("[");

              if(nextA == -1){

                     var go = str;

                     var spawn = "";

                     str = "";

              }else{

                     var go = str.substring(0,nextA);

                     var spawn = str.substring(str.indexOf("[") + 1,_pair(str.indexOf("["),str))

                     str = str.substring(_pair(str.indexOf("["),str) + 1,str.length);

              }

 

              // build a flat array of key/value pairs and strip out the empty elements

              var A = go.split(";");

              var A2 = new Array();

              for(var j=0;j<A.length;j++){

                     if(A[j].indexOf("!") != -1){

                            A2[A2.length] = A[j];

                     }

              }

              A = A2;

 

              // parse the flat array

              for(var i = 0;i < A.length;i++){

                     var tmpA = A[i].split("!");

                     var thisary = ary.length;

                     ary[thisary] = new Array();

 

                     // attach a sub array if needed

                     if((i+1)==A.length && spawn.length != ""){

                            ary[thisary] = _compile(ary[thisary],spawn);

                     }

                     // assign properties to this array based on the parsed array key/value pairs

                     ary[thisary].name = tmpA[0];

                     ary[thisary].url = tmpA[1];

                     ary[thisary].desc = tmpA[2];

                     ary[thisary].icon = tmpA[3];

              }

       }

}

///////////////////////

 

 

///////////////////////

//// Actually draw and initialize elements from the array

function _create(e,ary){

       var str = new String();

       var menuId = _menus.length;       // save the ID for this menu

       str   = '<DIV ID="_div_'

              + menuId              // give it a unique name

              + '" STYLE="visibility:hidden;position:absolute;top:0;left:0;width:'

              + e.attribs["width"]

              + ';height:10;background-color:black;">';

       e.insertAdjacentHTML("AfterEnd",str);       // paste it in below the root element

       var thismenu = document.all.item("_div_" + menuId);       // save a reference to the element object

       _menus[menuId] = thismenu;       // save a reference to the element object in a global array for later use

       thismenu.menuId = menuId;  // tell the element object where it is in the global array

       thismenu.close = _close; // assign a close function to it

       thismenu.menuParent = null; // initialize some variables to null

       thismenu.menuChild = null;

       thismenu.highlightBG = e.attribs["highlight"];

       thismenu.normalBG = e.attribs["background"];

       thismenu.menuOffset = e.attribs["menu-offset"];

       thismenu.menuTopoffset = e.attribs["menu-topoffset"];

       thismenu.waitDelay = e.attribs["wait"];

       var prevBottom = 0;             // initialize where the option elements should start drawing

 

       // create a span element for every option

       for(var i=0;i<ary.length;i++){

              str   = '<SPAN ID="_link_'   // assign a unique name

                     + menuId

                     + '_'

                     + i

                     + '" STYLE="position:absolute;top:'

                     + prevBottom        // position it correctly

                     + ';left:0;height:'

                     + e.attribs["height"]

                     + ';overflow:hidden;width:'

                     + e.attribs["width"]

                     + ';background:'

                     + e.attribs["background"]

                     + ';border-width:'

                     + e.attribs["border-width"]

                     + ';border-style:solid;border-color:'

                     + e.attribs["border-color"]

                     + ';';

              if(e.attribs["showrow"]!=true && i != 0){

                     str    +='border-top-width:0;';

              }

              str    +='text-align:left;font-size:'

                     + e.attribs["font-size"]

                     + ';padding-left:4;">';

              if(ary[i].icon!=null){

                     str    +='<SPAN STYLE="font-family:webdings;color:'

                            + e.attribs["icon-color"]

                            + '">&#'

                            + ary[i].icon

                            + ';</SPAN> ';

              }

              str    +='<A HREF="'

                     + ary[i].url

                     + '" TITLE="'

                     + ary[i].desc

                     + '" STYLE="font-family:'

                     + e.attribs["font-family"]

                     + ';color:'

                     + e.attribs["font-color"]

                     + ';padding-left:3;">'

                     + ary[i].name         // fill in the content/name

                     + '</A>';

              if(ary[i].length > 0 && e.attribs["arrow"]){

                     str    +='<SPAN STYLE="font-family:webdings;position:absolute;top:0;left:'

                            + e.attribs["arrow-offset"]

                            + ';width:'

                            + (e.attribs["width"] - e.attribs["arrow-offset"])

                            + ';overflow:hidden;color:'

                            + e.attribs["icon-color"]

                            + '">4</SPAN>';

              }

              str    +='</SPAN>';

              thismenu.insertAdjacentHTML("BeforeEnd",str);       // insert it inside the menu element

              thisoption = document.all.item('_link_' + menuId + '_' + i);

              thisoption.menuId = menuId; // save some references and initialize some variables

              thisoption.onmouseover = _optionmouseover;

              thisoption.onmouseout = _optionmouseout;

              prevBottom = thisoption.style.pixelTop + (e.attribs["height"] - e.attribs["border-width"]);      // where should the next one draw?

              if(ary[i].length > 0){            // uhoh, if there is a submenu here, better draw it!

                     thisoption.menuChild=_menus.length;  // tell this option that it has a child

                     _create(e,ary[i]);

              }

       }

       thismenu.style.pixelHeight = prevBottom;    // set the height on the menu element

}

/////////////////////

 

 

 

 

///////////////////////////////////////////

///////////////////////////////////////////

//// All the following are used on the "fly"

//// as needed during the documents life

////

////

 

 

var _menus = new Array();    // global array of menus

var _currentMenu = null;      // temporary storage of the current and current root menu elements

var _rootMenu = null;

var _rootKludge = null;

var _zIndex = 1;

 

/////////////////////

//// show the menu for this object

function _rootmouseover(){

       var e = window.event.srcElement;

       if(_rootMenu != null){

              _menus[_rootMenu].close();

       }

       _rootMenu = e.menuId; // store a temporary reference

       _rootKludge = e.menuId;

       var attribs = _eat_attrib(e.getAttribute("menu")); // initialize its position based on the config

       _menus[e.menuId].style.pixelTop = attribs["top"];

       _menus[e.menuId].style.pixelLeft = attribs["left"]

       _menus[e.menuId].style.visibility = "visible";

       _menus[e.menuId].style.zIndex = _zIndex++;

}

////////////////////

 

 

////////////////////

//// if the mouse leaves the main element,

//// try to close the displayed menu

function _rootmouseout(){

       _rootKludge = null;

       window.setTimeout("if(_rootKludge != " + _rootMenu + "){_menus[" + _rootMenu + "].close();}",_menus[_rootMenu].waitDelay);

}

////////////////////

 

 

////////////////////

//// nifty little IMPORTANT recursive function that

//// returns true only if the id to check

//// is in the heritage of the current menu!

function _heritage(menu,check){

       if(_menus[menu].menuId == check){

              return true;

       }else{

              // if I have a parent, check it, otherwise the answer is no

              if(_menus[menu].menuParent != null){

                     return _heritage(_menus[menu].menuParent,check);

              }else{

                     return false;

              }

       }

}

///////////////////

 

 

///////////////////

//// associated with every menu element object,

//// close this menu unless it is still active

function _close(){

       if(_currentMenu != null){

              if(_heritage(_currentMenu,this.menuId)){

                     return;

              }

       }

       if(this.menuChild != null){

              _menus[this.menuChild].close();

       }

       this.style.visibility = "hidden";

       this.menuChild = null;

       this.menuParent = null;

}

//////////////////

 

 

//////////////////

//// when the mouse passes over an option

function _optionmouseover(){

       // some ugly kludges to reduce flashing when the mouse passes through a subelement of the option

       if(window.event.srcElement.menuId==null && window.event.fromElement.id == window.event.srcElement.offsetParent.id){

              return;

       }

       if(window.event.fromElement.offsetParent!=null){

              if(window.event.fromElement.menuId==null && window.event.srcElement.id == window.event.fromElement.offsetParent.id){

                     return;

              }

       }

       if(window.event.srcElement.menuId==null){

              var e = window.event.srcElement.offsetParent;

       }else{

              var e = window.event.srcElement;

       }

       e.style.background = _menus[e.menuId].highlightBG;        // highlight it

       _currentMenu = e.menuId;           // reset the current menu

       if(_menus[_currentMenu].menuChild != null){   // close any previous children

              _menus[_menus[_currentMenu].menuChild].close();

       }

       if(e.menuChild!=null){         // if this option has a submenu, display it

              _menus[_currentMenu].menuChild = e.menuChild;     // tell the menu it has a child

              _menus[e.menuChild].menuParent = _currentMenu;   // tell the child it has a parent

              _menus[e.menuChild].style.pixelTop = _menus[_currentMenu].style.pixelTop + e.style.pixelTop + _menus[_currentMenu].menuTopoffset;

              _menus[e.menuChild].style.pixelLeft = _menus[_currentMenu].style.pixelLeft + _menus[_currentMenu].style.pixelWidth + _menus[_currentMenu].menuOffset;

              _menus[e.menuChild].style.visibility = "visible";

              _menus[e.menuChild].style.zIndex = _zIndex++;

       }

}

/////////////////

 

 

/////////////////

//// when the mouse leaves the option

function _optionmouseout(){

       // some ugly kludges to reduce flashing when the mouse passes through a subelement of the option

       if(window.event.srcElement.menuId==null && window.event.toElement.id == window.event.srcElement.offsetParent.id){

              return;

       }

       if(window.event.toElement.offsetParent!=null){

              if(window.event.toElement.menuId==null && window.event.srcElement.id == window.event.toElement.offsetParent.id){

                     return;

              }

       }

 

       if(window.event.srcElement.menuId==null){

              var e = window.event.srcElement.offsetParent;

       }else{

              var e = window.event.srcElement;

       }

       e.style.background = _menus[e.menuId].normalBG;          // unhighlight it

       var to = window.event.toElement.menuId;          // greener pasture?

       if(to!=null){   // leaving to a menu element

              if(to!=e.menuId){  // not this menu

                     _menus[_currentMenu].close();

              }else{                   // this menu, but hide any existing children

                     if(_menus[e.menuId].menuChild!=null){

                            _menus[_menus[e.menuId].menuChild].close();

                     }

              }

       }else{            // wait a bit, and close the whole menu

              window.setTimeout("_menus[_rootMenu].close()",_menus[_rootMenu].waitDelay);

       }

       _currentMenu = null;

}

 

function _eat_attrib(str){

       var chunks = new Array();

       var all = new Array();

 

       chunks=str.split(";");

 

       for(var i=0;i<chunks.length;i++){

              var tmpA = new Array();

              tmpA=chunks[i].split(":");

              all[tmpA[0]]=tmpA[1];

       }

       return all;

}

 

function _strip(str){

       var A = new Array();

 

       A = str.split("\t");

       str = A.join("");

 

       A = str.split("\n");

       str = A.join("");

 

       A = str.split("\r");

       str = A.join("");

 

       return str;

}

//////////////////

</SCRIPT>

 

<a href="default.htm" menu="top:60;left:200;src:menusrc;">Start</a>

<div id="menusrc" style="display:none;">

网页特效代码!http://www.7stk.com!Just a simple link to yahoo.;

Microsoft!http://www.microsoft.com!Go ahead and visit Microsoft's Home Page;

[

       Internet Explorer!http://www.microsoft.com/ie!Microsoft Internet Explorer;

       Internet Information Server!http://www.microsoft.com/iis!Ver 4 is VERY powerful;

]

新年祝福!http://www.7stk.com/fine/ny/n1.htm!The 'source' :);

</div>

 

1 Comments

Thu

26

Feb

2009

172、文字段在页面上飞舞

172、文字段在页面上飞舞

<SCRIPT>

 

function morph(e,wait,steps,style,done){

       if(e.morphing){

              return;

       }

       e.morphing = true;

       e.step = 0;

       e.done = steps;

       e.wait = wait;

       e.morphDone = done;

 

       // initialize the given element for the process

       // save some temporary variables within it

       var attribs = _eat_attrib(style);

       if(attribs["top"] != null){

              e.deltaTop = Math.round(Number((attribs["top"] - e.style.posTop) / steps));

              e.finalTop = attribs["top"];

       }else{

              e.deltaTop = null;

              e.finalTop = e.style.posTop;

       }

       if(attribs["left"] != null){

              e.deltaLeft = Math.round(Number((attribs["left"] - e.style.posLeft) / steps));

              e.finalLeft = attribs["left"];

       }else{

              e.deltaLeft = null;

              e.finalLeft = e.style.posLeft;

       }

       if(attribs["height"] != null){

              e.deltaHeight = Math.round(Number((attribs["height"] - e.style.posHeight) / steps));

              e.finalHeight = attribs["height"];

       }else{

              e.deltaHeight = null;

              e.finalHeight = e.style.posHeight;

       }

       if(attribs["width"] != null){

              e.deltaWidth = Math.round(Number((attribs["width"] - e.style.posWidth) / steps));

              e.finalWidth = attribs["width"];

       }else{

              e.deltaWidth = null;

              e.finalWidth = e.style.posWidth;

       }

 

       // group all of the coloring elements together

       e.colors = new Array();

       for(attrib in attribs){

              // check each one individually to kludge

              // if we need to use a "safe" name for the css attribute

              if(attrib == "background"){

                            e.colors[e.colors.length] = new Array();

                            e.colors[e.colors.length - 1].name = attrib;

                            e.colors[e.colors.length - 1].safename = attrib;

              }

              if(attrib == "color"){

                            e.colors[e.colors.length] = new Array();

                            e.colors[e.colors.length - 1].name = attrib;

                            e.colors[e.colors.length - 1].safename = attrib;

              }

              if(attrib == "border-color"){

                            e.colors[e.colors.length] = new Array();

                            e.colors[e.colors.length - 1].name = attrib;

                            e.colors[e.colors.length - 1].safename = "borderColor";

              }

       }

       for(var i=0;i<e.colors.length;i++){

              var rgb = _eat_rgb(attribs[e.colors[i].name]);

              var prergb = _eat_rgb(e.style[e.colors[i].safename]);

              e.colors[i].delta = _eat_rgb(attribs[e.colors[i].name]);

              e.colors[i].finish = _eat_rgb(attribs[e.colors[i].name]);

              e.colors[i].delta["red"] = Math.round(Number((rgb["red"] - prergb["red"]) / steps));

              e.colors[i].delta["green"] = Math.round(Number((rgb["green"] - prergb["green"]) / steps));

              e.colors[i].delta["blue"] = Math.round(Number((rgb["blue"] - prergb["blue"]) / steps));

       }

 

       // fire the first morphing step

       setTimeout("_morphing(document.all." + e.id + ")", wait);

}

/////////////////////////////

 

 

 

/////////////////////////////

//// private function that does the work of morphing the element

function _morphing(e){

       e.step++;

 

       if(e.deltaTop!=null){

              e.style.posTop += e.deltaTop;

       }

 

       if(e.deltaLeft!=null){

              e.style.posLeft += e.deltaLeft;

       }

 

       if(e.deltaHeight!=null){

              e.style.posHeight += e.deltaHeight;

       }

 

       if(e.deltaWidth!=null){

              e.style.posWidth += e.deltaWidth;

       }

 

 

       for(var i=0;i<e.colors.length;i++){

              var rgb = _eat_rgb(e.style[e.colors[i].safename]);

              e.style[e.colors[i].safename]        = "rgb("

                                          + (e.colors[i].delta["red"] + rgb["red"])

                                          + ","

                                          + (e.colors[i].delta["green"] + rgb["green"])

                                          + ","

                                          + (e.colors[i].delta["blue"] + rgb["blue"])

                                          + ")";

       }

 

       // do special things when we are done

       if(e.step == e.done){

              if(e.deltaTop != null)

                     e.style.posTop = e.finalTop;

              if(e.deltaLeft != null)

                     e.style.posLeft = e.finalLeft;

              if(e.deltaWidth != null)

                     e.style.posWidth = e.finalWidth;

              if(e.deltaHeight != null)

                     e.style.posHeight = e.finalHeight;

              for(var i=0;i<e.colors.length;i++){

                     e.style[e.colors[i].safename]        = "rgb("

                                                 + (e.colors[i].finish["red"] + rgb["red"])

                                                 + ","

                                                 + (e.colors[i].finish["green"] + rgb["green"])

                                                 + ","

                                                 + (e.colors[i].finish["blue"] + rgb["blue"])

                                                 + ")";

              }

              e.morphing = false;

              eval(e.morphDone);

       }else{

              setTimeout("_morphing(document.all." + e.id + ")", e.wait);

       }

       return;

}

 

 

//////////////////

//// util for element attribute parsing

//// returns an array of all of the keys = values

function _eat_attrib(str){

       var chunks = new Array();

       var all = new Array();

 

       chunks=str.split(";");

 

       for(var i=0;i<chunks.length;i++){

              var tmpA = new Array();

              tmpA=chunks[i].split(":");

              all[tmpA[0]]=tmpA[1];

       }

       return all;

}

////////////////////

 

 

//////////////////

//// util for style rgb(#,#,#) parsing

//// returns an array of red/green/blue = number

function _eat_rgb(str){

       var all = new Array();

 

       var a = str.indexOf("(");

       var b = str.indexOf(")");

 

       str = str.substring(a + 1, b);

 

       var tmpA = str.split(",");

 

       all["red"]=Number(tmpA[0]);

       all["green"]=Number(tmpA[1]);

       all["blue"]=Number(tmpA[2]);

 

       return all;

}

////////////////////

 

</SCRIPT>

<SPAN ID="test" STYLE="border:solid;border-width:5;border-color:rgb(0,0,0);color:rgb(255,255,255);position:absolute;top:0;left:0;width:400;height:400;overflow:hidden;background:rgb(0,0,255);">

欢迎光临 <B>www.7stk.com</B> 网页特效站,请多提意见!!

</SPAN>

<SCRIPT>

function rander(){

       var top = Math.round(Math.random() * 400);

       var left = Math.round(Math.random() * 600);

       var width = Math.round(Math.random() * 200);

       var height = Math.round(Math.random() * 200);

       var r = Math.round(Math.random() * 255);

       var g = Math.round(Math.random() * 255);

       var b = Math.round(Math.random() * 255);

       var background = "rgb(" + r + "," + g + "," + b + ")";

       var r = Math.round(Math.random() * 255);

       var g = Math.round(Math.random() * 255);

       var b = Math.round(Math.random() * 255);

       var borderColor = "rgb(" + r + "," + g + "," + b + ")";

       var r = Math.round(Math.random() * 255);

       var g = Math.round(Math.random() * 255);

       var b = Math.round(Math.random() * 255);

       var color = "rgb(" + r + "," + g + "," + b + ")";

       morph(document.all.test,30,20,"top:" + top + ";left:" + left + ";width:" + width + ";height:" + height + ";background:" + background + ";border-color:" + borderColor + ";color:" + color + ";","rander();");

}

 

rander();

 

</SCRIPT>

 

 

 

 

0 Comments

Thu

26

Feb

2009

171、按钮驱动文字渐变

171、按钮驱动文字渐变

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

var x=9;

var strobe="on"

if (navigator.appName == "Netscape") {

visShow="'show'";

visHide="'hide'";

docStyle="document.";

styleDoc="";

}

else {

visHide="'hidden'";

visShow="'visible'";

docStyle="";

styleDoc=".style";

}

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">

function hide1() {

eval(docStyle+ 'object1' + styleDoc + '.visibility=' + visHide);

}

function hide2() {

eval(docStyle+ 'object2' + styleDoc + '.visibility=' + visHide);

}

function hide3() {

eval(docStyle+ 'object3' + styleDoc + '.visibility=' + visHide);

}

function hide4() {

eval(docStyle+ 'object4' + styleDoc + '.visibility=' + visHide);

}

function hide5() {

eval(docStyle+ 'object5' + styleDoc + '.visibility=' + visHide);

}

function hide6() {

eval(docStyle+ 'object6' + styleDoc + '.visibility=' + visHide);

}

function hide7() {

eval(docStyle+ 'object7' + styleDoc + '.visibility=' + visHide);

}

function hide8() {

eval(docStyle+ 'object8' + styleDoc + '.visibility=' + visHide);

}

function hide9() {

eval(docStyle+ 'object9' + styleDoc + '.visibility=' + visHide);

}

function hide10() {

eval(docStyle+ 'object10' + styleDoc + '.visibility=' + visHide);

}

function show1() {

eval(docStyle+ 'object1' + styleDoc + '.visibility=' + visShow);

hide2(),hide3();

}

function show2() {

eval(docStyle+ 'object2' + styleDoc + '.visibility=' + visShow);

hide1(),hide3();

}

function show3() {

eval(docStyle+ 'object3' + styleDoc + '.visibility=' + visShow);

hide2(),hide4();

}

function show4() {

eval(docStyle+ 'object4' + styleDoc + '.visibility=' + visShow);

hide3(),hide5();

}

function show5() {

eval(docStyle+ 'object5' + styleDoc + '.visibility=' + visShow);

hide4(),hide6();

}

function show6() {

eval(docStyle+ 'object6' + styleDoc + '.visibility=' + visShow);

hide5(),hide7();

}

function show7() {

eval(docStyle+ 'object7' + styleDoc + '.visibility=' + visShow);

hide6(),hide8();

}

function show8() {

eval(docStyle+ 'object8' + styleDoc + '.visibility=' + visShow);

hide7(),hide9();

}

function show9() {

eval(docStyle+ 'object9' + styleDoc + '.visibility=' + visShow);

hide8(),hide10();

}

function show10() {

eval(docStyle+ 'object10' + styleDoc + '.visibility=' + visShow);

hide9();

}

function strobe1() {

x+=1;

eval("show" + x + "()");

if (x<10) setTimeout("strobe1()", 75);

else if (strobe=="on") strobe2();

}

function strobe2() {

x-=1;

eval("show" + x + "()");

if (x>1) setTimeout("strobe2()", 75);

else strobe1();

}

function strobeOn() {

x=9;

strobe="on";

strobe1();

}

function strobeOff() {

strobe="off";

}

</SCRIPT>

<div id="vis" style="position:absolute; visibility:show; left:175px; top:280px; z-index:1">

<table cellpadding=2 border=1><tr>

<td><center><b>Strobe:</b></center></font></a></td>

<td><a href="javascript:strobeOn()">

<font color="#000000"><center>on</center></font></a></td>

<td><a href="javascript:strobeOff()">

<font color="#000000"><center>off</center></font></a></td>

</tr></table></div>

 

<div id="object1" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=#eaffff width=175 height=50><td><center><b><font color="#F9F9F9">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object2" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#ECECEC">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object3" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#D5D5D5">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object4" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#C0C0C0">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object5" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#b0b0b0">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object6" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#939393">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object7" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#808080">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object8" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#6b6b6b">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object9" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#424242">JavaScript Planet</font></b></center></td></table>

</div>

<div id="object10" style="position:absolute; visibility:show; left:175px; top:300px; z-index:1">

<table border=1 bgcolor=eaffff width=175 height=50><td><center><b><font color="#000000">JavaScript Planet</font></b></center></td></table>

</div><P>

</FONT></CENTER>

 

0 Comments

Thu

26

Feb

2009

170、文字向左移动

170、文字向左移动

脚本说明:

把如下代码加入<body>区域中:

<script language="JavaScript1.2">

//设置marquee的宽度 (in pixels)

var marqueewidth=400

//设置marquee的高度 (in pixels, 该参数只适用于NS)

var marqueeheight=20

//设置marquee滚动的速度(数值大速度快)

var speed=4

//设置marquee显示内容,使用标准的HTML语法。

var marqueecontents='<strong><big>欢迎光临<a href="http://www.7stk.com">网页制作特效</a> javascript的精彩世界 </big></strong></font>'

if (document.all)

document.write('<marquee scrollAmount='+speed+' style="width:'+marqueewidth+'">'+marqueecontents+'</marquee>')

function regenerate(){

window.location.reload()

}

function regenerate2(){

if (document.layers){

setTimeout("window.onresize=regenerate",450)

intializemarquee()

}

}

function intializemarquee(){

document.cmarquee01.document.cmarquee02.document.write('<nobr>'+marqueecontents+'</nobr>')

document.cmarquee01.document.cmarquee02.document.close()

thelength=document.cmarquee01.document.cmarquee02.document.width

scrollit()

}

function scrollit(){

if (document.cmarquee01.document.cmarquee02.left>=thelength*(-1)){

document.cmarquee01.document.cmarquee02.left-=speed

setTimeout("scrollit()",100)

}

else{

document.cmarquee01.document.cmarquee02.left=marqueewidth

scrollit()

}

}

window.onload=regenerate2

</script>

<ilayer width=&{marqueewidth}; height=&{marqueeheight}; name="cmarquee01">

<layer name="cmarquee02"></layer>

</ilayer>

 

0 Comments

Thu

26

Feb

2009

169、文字弯曲变形

169、文字弯曲变形

脚本说明:

把如下代码加入<body>区域中:

<span STYLE="position:relative; width:200; height:50; filter:wave(Add=0,Freq=5,LightStrength=10,Phase=1,Strength=3)"><p>

<font color="#FF0000">欢迎光临7stk.com网页制作特效站,请多提意见!!!</font></p></span>

 

0 Comments

Thu

26

Feb

2009

168、文字从小变大

168、文字从小变大

脚本说明:

第一步:把如下代码加入<body>区域中

<style type="text/css">

body

        {

        background-color:#FFFFFF;

        font-family: Arial;

        font-size:10pt;

        }

 

 

</style>

 

<script>

 

 

        text=new Array('www','7stk','com','网页特效代码')

 

        var numText=4

 

        color=new Array('#000000','#2F2F2F','#4F4F4F','#7F7F7F','#408080')

 

        var numColors=5

 

        var endSize=70

 

        var Zspeed=30

 

        var Cspeed=200

 

        var font='Arial Black'

 

        var hide=false

 

var size=10

 

var gonum=0

 

var ie, n;

 

if (document.all) {

 

                n=0

 

                ie=1

 

                zoomText='document.all.zoom.innerText=text[num]'

 

                zoomSize='document.all.zoom.style.fontSize=size'

 

                closeIt=""

 

                fadeColor="document.all.zoom.style.color=color[num]"

 

        }

 

if (document.layers) {

 

                n=1;ie=0

 

                zoomText=""

 

                zoomSize="document.zoom.document.write('<p align=\"center\" style=\"font-family:'+font+'; font-size:'+size+'px; color:'+color[0]+'\">'+text[num]+'</p>')"

 

                closeIt="document.zoom.document.close()"

 

                fadeColor="document.zoom.document.write('<p align=\"center\" style=\"font-family:'+font+'; font-size:'+endSize+'px; color:'+color[num]+'\">'+text[numText-1]+'</p>')"

 

        }

 

 

function zoom(num,fn){

 

        if (size<endSize){

 

                eval(zoomText)

 

                eval(zoomSize)

 

                eval(closeIt)

 

                size+=5;

 

                setTimeout("zoom("+num+",'"+fn+"')",Zspeed)

 

        }else{

 

                eval(fn);

 

        }

 

}

 

 

function fadeIt(num){

 

        if (num<numColors){

 

                eval(fadeColor)

 

                eval(closeIt)

 

                num+=1;

 

                setTimeout("fadeIt("+num+")",Cspeed)

 

        }else{

 

                hideIt()

 

        }

 

}

 

 

function hideIt(){

 

        if(hide){

 

                if(ie)document.all.zoom.style.visibility="hidden"

 

                if(n)document.layers.zoom.visibility="hidden"

 

        }

 

}

 

 

function init(){

 

        if(ie){

 

                document.all.zoom.style.color=color[0]

 

                document.all.zoom.style.fontFamily=font

 

        }

 

        if(ie || n) go(0)      

 

}

 

function go(num){

 

        gonum+=1

 

        size=10

 

        if(num<numText){

 

                zoom(num,'go('+gonum+')')

 

        }else{

 

                fadeIt(0)

 

        }

 

}

 

</script>

<div id="zoom" align="center" style="position:absolute; top:150">

 

0 Comments

Thu

26

Feb

2009

167、文字循环隐现

167、文字循环隐现

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript1.2">

<!-- Begin

ie4 = ((navigator.appVersion.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) >= 4));

var count = 0, count2 = 0, add1 = 3, add2 = 10, timerID;

function show() {

if (ie4) {

count += add1;

count2 += add2;

delay = 30;

if(count2 > 100) count2 = 100;

if(count > 100) {

count = 100;

add1 = -10;

add2 = -3;

delay = 350;

}

if(count < 0) count = 0;

if(count2 < 0) {

count2 = 0;

add1 = 3;

add2 = 10;

delay = 200;

}

fader.style.filter = "Alpha(Opacity="+count2+",FinishOpacity="+count+",style=2)";

timerID = setTimeout("show()", delay);

   }

}

window.onload = show;

//  End -->

</script>

<div id="fader" style="width:480; Filter:Alpha(Opacity=0,FinishOpacity=0,style=2)">

<h1>

<font family="Arial, Helvetica" color="maroon" size="+3">

welcome to

<br>

www.7stk.com

<br>

thank you!

</font>

</h1>

</div>

0 Comments

Thu

26

Feb

2009

166、层的显示与关闭

166、层的显示与关闭

脚本说明:

把如下代码加入<body>区域中:

<script LANGUAGE="JavaScript">

 function showOrHide(value) {

    if (value==0) {

        if (document.layers)

           document.layers["layer1"].visibility='hide';

        else

           document.all["layer1"].style.visibility='hidden';

   }

   else if (value==1) {

       if (document.layers)

          document.layers["layer1"].visibility='show';

       else

          document.all["layer1"].style.visibility='visible';

   }

}

</script>

<form NAME="form1">

<input TYPE="button" VALUE=" " onClick="showOrHide(1);">

<input TYPE="button" VALUE=" " onClick="showOrHide(0);">

</form>

<div ID="layer1" style="position:absolute; LEFT:45; TOP:70; background-color:#BFE3C0; width:120;height:100; visibility:hidden">

<font color=blue><b>欢迎你的光临!</b></font><br>

<font color="#7E059C">这个脚本很有用的,具体的你自己想想</font></div>

 

0 Comments

Thu

26

Feb

2009

165、文字逐个变成大写

165、文字逐个变成大写

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

ripplespeed = 300; // lower = faster

string = "Welcome to the www.7stk.com";

 

function rippleText() {

box = document.scrollform.box; // box to display text in

arg0 = rippleText.arguments[0];

i = (arg0) ? ( (arg0 == string.length) ? 0 : arg0) : 0;

 

box.value = string.substring(0,i)

+ (string.substring(i,i+1).toUpperCase())

+ string.substring(i+1, string.length);

 

scrollcmd = "rippleText("+(i+1)+")";

timer = window.setTimeout(scrollcmd, ripplespeed);

}

//  End -->

</script>

<center>

<form name=scrollform>

<input type=text name=box size=30>

</form>

</center>

 

 

 

第二步:把<body>区域中的内容改为

<body bgcolor="#fef4d9" OnLoad="rippleText()">

 

0 Comments

Thu

26

Feb

2009

164、文字抖动

164、文字抖动

脚本说明:

第一步:把如下代码加入<body>区域中:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

dw=0;   //change in width;

dh=0;   //change in height;

function jitter() {

w = (Math.round(Math.random()*10)%5)-2; dw+=w;

h = (Math.round(Math.random()*10)%5)-2; dh+=h;

if (dh>10) {h=(0-11);dh=0;}

else if (dh<(0-10)) {h=11;dh=0;}

if (dw>10) {w=(0-11);dw=0;}

else if (dw<(0-10)) {w=11;dw=0;}

vers = parseInt(navigator.appVersion);

if (vers>=4) {

if (navigator.appName=="Netscape") {

document.jitterText.left+=w;

document.jitterText.top+=h;

}

else if (navigator.appName=="Microsoft Internet Explorer") {

document.all.jitterText.style.pixelLeft+=w;

document.all.jitterText.style.pixelTop+=h;

}

setTimeout("jitter()",100);

}

else {} // browser can't view effect

}

// End -->

</SCRIPT>

<STYLE TYPE="text/css">

#jitterText {

position: absolute; left: 0; top: 300; font-size:24pt;

background:white; color:red; }

</STYLE>

 

<DIV ID="jitterText">

<center>网页特效代码</center>

</DIV>

 

第二步:<body>中的内容改为

<body bgcolor="#fef4d9" OnLoad="jitter()">

 

0 Comments

Thu

26

Feb

2009

163、数字翻译成英文

163、数字翻译成英文

脚本说明:

把如下代码加入<body>区域中:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var n = "";

function validate(input) {

if (input.length == 0) {

alert ('请输入一个数字');

document.myform.textver.value = "";

return true;

}

else convert(input);

}

function d1(x) { // single digit terms

switch(x) {

case '0': n= ""; break;

case '1': n= " One "; break;

case '2': n= " Two "; break;

case '3': n= " Three "; break;

case '4': n= " Four "; break;

case '5': n= " Five "; break;

case '6': n= " Six "; break;

case '7': n= " Seven "; break;

case '8': n= " Eight "; break;

case '9': n= " Nine "; break;

default: n = "Not a Number";

}

return n;

}

function d2(x) { // 10x digit terms

switch(x) {

case '0': n= ""; break;

case '1': n= ""; break;

case '2': n= " Twenty "; break;

case '3': n= " Thirty "; break;

case '4': n= " Forty "; break;

case '5': n= " Fifty "; break;

case '6': n= " Sixty "; break;

case '7': n= " Seventy "; break;

case '8': n= " Eighty "; break;

case '9': n= " Ninety "; break;

default: n = "Not a Number";

}

return n;

}

function d3(x) { // teen digit terms

switch(x) {

case '0': n= " Ten "; break;

case '1': n= " Eleven "; break;

case '2': n= " Twelve "; break;

case '3': n= " Thirteen "; break;

case '4': n= " Fourteen "; break;

case '5': n= " Fifteen "; break;

case '6': n= " Sixteen "; break;

case '7': n= " Seventeen "; break;

case '8': n= " Eighteen "; break;

case '9': n= " Nineteen "; break;

default: n=  "Not a Number";

}

return n;

}

function convert(input) {

var inputlength = input.length;

var x = 0;

var teen1 = "";

var teen2 = "";

var teen3 = "";

var numName = "";

var invalidNum = "";

var a1 = ""; // for insertion of million, thousand, hundred

var a2 = "";

var a3 = "";

var a4 = "";

var a5 = "";

digit = new Array(inputlength); // stores output

for (i = 0; i < inputlength; i++)  {

// puts digits into array

digit[inputlength - i] = input.charAt(i)};

store = new Array(9); // store output

for (i = 0; i < inputlength; i++) {

x= inputlength - i;

switch (x) { // assign text to each digit

case x=9: d1(digit[x]); store[x] = n; break;

case x=8: if (digit[x] == "1") {teen3 = "yes"}

          else {teen3 = ""}; d2(digit[x]); store[x] = n; break;

case x=7: if (teen3 == "yes") {teen3 = ""; d3(digit[x])}

          else {d1(digit[x])}; store[x] = n; break;

case x=6: d1(digit[x]); store[x] = n; break;

case x=5: if (digit[x] == "1") {teen2 = "yes"}

          else {teen2 = ""}; d2(digit[x]); store[x] = n; break;

case x=4: if (teen2 == "yes") {teen2 = ""; d3(digit[x])}   

          else {d1(digit[x])}; store[x] = n; break;

case x=3: d1(digit[x]); store[x] = n; break;

case x=2: if (digit[x] == "1") {teen1 = "yes"}

          else {teen1 = ""}; d2(digit[x]); store[x] = n; break;

case x=1: if (teen1 == "yes") {teen1 = "";d3(digit[x])}    

          else {d1(digit[x])}; store[x] = n; break;

}

if (store[x] == "Not a Number"){invalidNum = "yes"};

switch (inputlength){

case 1:   store[2] = "";

case 2:   store[3] = "";

case 3:   store[4] = "";

case 4:   store[5] = "";

case 5:   store[6] = "";

case 6:   store[7] = "";

case 7:   store[8] = "";

case 8:   store[9] = "";

}

if (store[9] != "") { a1 =" Hundred, "} else {a1 = ""};

if ((store[9] != "")||(store[8] != "")||(store[7] != ""))

{ a2 =" Million, "} else {a2 = ""};

if (store[6] != "") { a3 =" Hundred "} else {a3 = ""};

if ((store[6] != "")||(store[5] != "")||(store[4] != ""))

{ a4 =" Thousand, "} else {a4 = ""};

if (store[3] != "") { a5 =" Hundred "} else {a5 = ""};

}

// add up text, cancel if invalid input found

if (invalidNum == "yes"){numName = "对不起,你输入的不是数字!"}

else {

numName =  store[9] + a1 + store[8] + store[7]

+ a2 + store[6] + a3 + store[5] + store[4]

+ a4 + store[3] + a5 + store[2] + store[1];

}

store[1] = ""; store[2] = ""; store[3] = "";

store[4] = ""; store[5] = ""; store[6] = "";

store[7] = ""; store[8] = ""; store[9] = "";

if (numName == ""){numName = "Zero"};

document.myform.textver.value = numName;

return true;

}

//  End -->

</script>

请输入一个0999,999,999之间的数字

<form name="myform">

<table border=0>

<tr>

<td>数字</td>

<td><input name="numver" size=9 maxlength=9> <input onclick="return validate(document.myform.numver.value)" type="button" value="翻译数字"></td>

</tr>

<tr>

<td>英文翻译</td>

<td><input name="textver" size=50 maxlength=50></td>

</tr>

<tr>

<td align=middle colspan=2></td>

</tr>

</table>

</form>

 

0 Comments

Thu

26

Feb

2009

162、文字飞舞欢迎

162、文字飞舞欢迎

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT>

<!-- Beginning of JavaScript -

var your_message="www.7stk.com"

var textfont="Verdana"

var textsize=20

var textcolor="006600"

var textboldness=7

var tempo=40

var stepx=30

var stepy=20

var msg=new Array()

var msg=your_message

var message=msg.split("")

var numberofletters=msg.length-1

var x,y

var marginbottom

var marginleft=0

var margintop=0

var marginright

textboldness=textboldness*100

var timer

var xpos=new Array()

var ypos=new Array()

var spancontent=new Array()

 

for (i=0; i<=numberofletters;i++) {

    xpos[i]=0

       ypos[i]=0

}

 

for (i=0;i<=numberofletters;i++) {

       spancontent[i]="<span style='position:relative;font-family:"+textfont+";font-size:"+textsize+"pt;color:"+textcolor+";font-weight:"+textboldness+"'>"+message[i]+"</span>"

}

 

function setValues() {

    var firsttimer= setTimeout("setValues2()",2000)

}

 

function setValues2() {

       if (document.all) {

           marginbottom = document.body.clientHeight-5

           marginright = document.body.clientWidth-5

              for (i=0;i<=numberofletters;i++) {            

                     var thisspan = eval("document.all.span"+i)

                  thisspan.innerHTML=spancontent[i]

                     var thisspan = eval("document.all.span"+(i)+".style")

             thisspan.posLeft=0

                     thisspan.postop=0 

              }

              moveball()

       }

      

       if (document.layers) {

           marginbottom = window.innerHeight-10

           marginright = window.innerWidth-10

              for (i=0;i<=numberofletters;i++) {            

                     var thisspan=eval("document.span"+i+".document")

                  thisspan.write(spancontent[i])

                     thisspan.close()

                     var thisspan=eval("document.span"+i)

             thisspan.left=0

                     thisspan.top=0 

              }

           moveball()

       }

}

 

function randommaker(range) {          

       rand=Math.floor(range*Math.random())

    return rand

}

 

function moveball() {

       if (document.all) {

              checkposition()

            makesnake()

            document.all.span0.style.posTop+=stepy

           timer=setTimeout("moveball()",tempo)

       }

       if (document.layers) {

              checkposition()

            makesnake()

            document.span0.top+=stepy

           timer=setTimeout("moveball()",tempo)

       }

}

 

function makesnake() {

              for (i=numberofletters; i>=1; i--) {

                   xpos[i]=xpos[i-1]

                     ypos[i]=ypos[i-1]

           }

              if (document.all) {

                     xpos[0]=document.all.span0.style.posLeft+stepx

                     ypos[0]=document.all.span0.style.posTop+stepy

                     for (i=0;i<=numberofletters;i++) { 

                         var thisspan=eval("document.all.span"+(i)+".style")

                         thisspan.posLeft=xpos[i]

                            thisspan.posTop=ypos[i]

                  }

              }

              if (document.layers) {

                     xpos[0]=document.span0.left+stepx

                     ypos[0]=document.span0.top+stepy

                     for (i=0;i<=numberofletters;i++) { 

                         var thisspan = eval("document.span"+i)

                         thisspan.left=xpos[i]

                            thisspan.top=ypos[i]

                  }

              }

}

 

function checkposition() {

       if (document.all) {

              if (document.all.span0.style.posLeft>marginright) {

                     stepx=(stepx+randommaker(2))*-1

                     document.all.span0.style.posLeft-=1

              }

              if (document.all.span0.style.posLeft<marginleft) {

                     stepx=(stepx+randommaker(2))*-1

                     document.all.span0.style.posLeft+=1

              }    

              if (document.all.span0.style.posTop>marginbottom) {

                     stepy=(stepy+randommaker(2))*-1

                     document.all.span0.style.posTop-=1

              }

              if (document.all.span0.style.posTop<margintop) {

                     stepy=(stepy+randommaker(2))*-1

                     document.all.span0.style.posTop+=1

              }

       }

       if (document.layers) {

              if (document.span0.left>=marginright) {

                     stepx=(stepx+randommaker(2))*-1

                     document.span0.left-=10

              }

              if (document.span0.left<=marginleft) {

                     stepx=(stepx+randommaker(2))*-1

                     document.span0.left+=10

              }    

              if (document.span0.top>=marginbottom) {

                     stepy=(stepy+randommaker(2))*-1

                     document.span0.top-=10

              }

              if (document.span0.top<=margintop) {

                     stepy=(stepy+randommaker(2))*-1

                     document.span0.top+=10

              }

       }

}

// - End of JavaScript - -->

</SCRIPT>

  <SCRIPT>

<!-- Beginning of JavaScript -

 

for (i=0;i<=numberofletters;i++) {

    document.write("<span id='span"+i+"' style='position:absolute'></span>")

    document.close()

}

 

// - End of JavaScript - -->

</SCRIPT>

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onload=setValues()>

 

       

 

0 Comments

Thu

26

Feb

2009

161、文字蜿蜒飞舞

161、文字蜿蜒飞舞

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT>

<!--

var mes = new Array()

mes[0]="欢迎光临 www.7stk.com! "

mes[1]="这里有大量有趣的javascript特效脚本! "

mes[2]="大部分脚本来自外国站点与斑竹原创. "

mes[3]="ASPPHPCGI各种程序. "

mes[4]="引本站的脚本请注明出处."

 

var maxtextlength=30

// 下以为路线,中间不能有空格

var path= new Array(548,316,581,296,598,257,577,215,559,202,503,193,464,203,446,222,448,255,468,274,500,280,526,267,541,237,537,209,526,187,499,161,462,146,412,133,368,129,326,132,293,142,272,159,250,184,239,204,234,213,226,230,201,253,186,259,165,265,136,268,110,270,83,267,58,260,36,243,26,229,22,210,24,191,29,174,39,163,56,154,76,150,96,149,110,148,135,152,165,156,196,165,208,172,231,181,254,192,280,203,305,210,339,210,366,206,389,195,405,182,419,167,428,148,442,116,448,80,443,41,401,8,347,0,300,11,280,30,256,50,230,58,198,61,169,56,141,50,113,45,87,36,70,29,52,24,28,18,7,15)

 

// 第二个信息间隔多久出现

var stoptime=5

 

// 字体的属性

var textfont="宋体"

var textsize=12

var textcolor="006600"

 

// 字符的间距,如果你改变字体的大小也要改变这里

var letterspace=12

 

var tickerleft=path[path.length-2]

var tickertop=path[path.length-1]

var timer

var finalxpos=tickerleft

var i_mes=0

var message=""

var i_path=0

var stoptimemilli=stoptime*stoptime+1000

var pathx= new Array()

 

if (document.layers) {

       if (textsize>20) {textsize=6}

       else if (textsize>20) {textsize=5}

       else if (textsize>14) {textsize=4}

       else if (textsize>10) {textsize=3}

       else if (textsize>8) {textsize=2}

       else if (textsize<=7) {textsize=1}

}

 

var ii=0

for (i=0;i<=path.length-1;i=i+2) {

       pathx[ii]=path[i]

       ii++

}

 

ii=0

 

var pathy= new Array()

for (i=1;i<=path.length-1;i=i+2) {

       pathy[ii]=path[i]

       ii++

}

 

var xpos=new Array()

for (i=0;i<=maxtextlength;i++) {

       xpos[i]=5000

}

 

var ypos=new Array()

for (i=0;i<=maxtextlength;i++) {

       ypos[i]=5000

}

 

function makesnake() {

       if (i_path<=pathx.length-1) {

              for (i=message.length-1; i>=1; i--) {

                   xpos[i]=xpos[i-1]

                     ypos[i]=ypos[i-1]

           }

              xpos[0]=pathx[i_path]

              ypos[0]=pathy[i_path]

              if (document.all) {

                     for (i=0; i<message.length-1; i++) {

                         var thisspan = eval("document.all.span"+(i)+".style")

                         thisspan.posLeft=xpos[i]

                            thisspan.posTop=ypos[i]

                  }

              }

              if (document.layers) {

                     for (i=0; i<message.length-1; i++) {

                         var thisspan = eval("document.span"+i)

                         thisspan.left=xpos[i]

                            thisspan.top=ypos[i]

                  }

              }

              i_path++

              timer=setTimeout("makesnake()",20)

       }

       else {

              clearTimeout(timer)

              endposition()

       }

}

 

function endposition() {

              if (document.all) {

                     for (i=0; i<message.length-1; i++) {

                         var thisspan = eval("document.all.span"+(i)+".style")

                         thisspan.posLeft=tickerleft+finalxpos

                            thisspan.posTop=tickertop

                            finalxpos+=letterspace

                  }

              }

              if (document.layers) {

                     for (i=0; i<message.length-1; i++) {

                         var thisspan = eval("document.span"+i)

                         thisspan.left=tickerleft+finalxpos

                            thisspan.top=tickertop

                            finalxpos+=letterspace

                  }

              }

              timer=setTimeout("clearmessage()",stoptimemilli)

}

 

function clearmessage() {

              finalxpos=tickertop

              i_path=0

              for (i=0;i<=maxtextlength;i++) {

                     xpos[i]=5000

              }

              if (document.all) {

                     for (i=0;i<=maxtextlength;i++) {

                            var thisspan = eval("document.all.span"+i)

                         thisspan.innerHTML=" "

                            var thisspan = eval("document.all.span"+(i)+".style")

                         thisspan.posLeft=xpos[i]=5000

                     }

              }

              if (document.layers) {

                     for (i=0;i<=maxtextlength;i++) {

                            var thisspan = eval("document.span"+i+".document")

                         thisspan.write("<p> </p>")

                            thisspan.clear()

                            thisspan = eval("document.span"+i)

                         thisspan.left=5000

                     }

              }

              timer=setTimeout("changemessage()",2000)

}

 

function changemessage() {

              var messa=mes[i_mes]

              message=messa.split("")

              if (document.all) {

                     for (i=0;i<=message.length-1;i++) {

                            var thisspan = eval("document.all.span"+i)

                         thisspan.innerHTML="<p style='font-family:"+textfont+";font-size:"+textsize+";color:"+textcolor+"'>"+message[i]+"</p>"

                     }

              }

              if (document.layers) {

                     for (i=0; i<message.length-1; i++) {

                         var thisspan=eval("document.span"+i+".document")

                         thisspan.write("<p><font size="+textsize+" color="+textcolor+" face="+textfont+">"+message[i]+"</font></p>")

                            thisspan.clear()

                  }

              }

              i_mes++

              if (i_mes>=mes.length) {i_mes=0}

              finalxpos=tickertop

              i_path=0

              timer=setTimeout("makesnake()",1000)

}

 

// - End of JavaScript - -->

</SCRIPT>

<STYLE>.spanstyle {

       LEFT: 5000px; POSITION: absolute; VISIBILITY: visible

}

</STYLE>

<SCRIPT>

<!-- Beginning of JavaScript -

       for (i=0;i<=maxtextlength;i++) {

           document.write("<span id='span"+i+"' class='spanstyle'>")

              document.write(message)

           document.write("</span>")

       }

 

// - End of JavaScript - -->

</SCRIPT>

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onload=changemessage()>

 

0 Comments

Thu

26

Feb

2009

160、各种文字特性

160、各种文字特性

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

function reverse() {

text = "";

str = document.forms[0].elements[0].value=document.forms[0].elements[0].value;

for (i = 0; i <= str.length; i++)

text = str.substring(i, i+1) + text;

document.forms[0].elements[0].value = document.forms[0].elements[0].value = text;

}

function lower() {

document.forms[0].elements[0].value = document.forms[0].elements[0].value.toLowerCase()

}

function caps() {

document.forms[0].elements[0].value = document.forms[0].elements[0].value.toUpperCase()

}

function whatIsThis() {

document.forms[0].elements[0].value = escape(document.forms[0].elements[0].value)

}

function dontLikeThis() {

document.forms[0].elements[0].value = unescape(document.forms[0].elements[0].value)

}

var t = new Array();

t[0] = "Here is some text to use as an example. Click on reverse, uppercase, or lowercase.";

function example() {

for(var i = 0; i < 2; i++) {

if(document.forms[0].elements[i].value) {

document.forms[0].elements[0].value = document.forms[0].elements[0].value+unescape(t[0]);

      }

   }

}

var f = new Array();

f[0] = "%3Ca%20href%3D%27http%3A//www.1stscript.com%27%3E%3Cimg%20src%3D%22http%3A//www.1stscript.com/img/logo.gif%22%20alt%3D%27网络编程%21%27%20border%3D0%3E%3C/a%3E";

function exAscii() {

for(var i = 0; i < 2; i++) {

if(document.forms[0].elements[i].value) {

document.forms[0].elements[0].value = document.forms[0].elements[0].value+unescape(f[0]);

      }

   }

}

//  End -->

</script>

<form action="" method="post">

<textarea rows=10 cols=40 wrap=soft></textarea>

<table border=0><center>

<tr><td>

<input type=button value="例子"onClick="example(this.form)">

<input type=button value="字母反转" onClick="reverse()">

<input type=button value="字母大写" onClick="caps()">

<input type=button value="字母小写" onClick="lower()">

</td>

</tr>

<tr>

<td>

<input type=button value="Ascii例子" onClick="exAscii()">

<input type=button value="UnAscii" onClick="dontLikeThis()">

<input type=button value="Ascii" onClick="whatIsThis()">

<input type=button value="清除" onClick="reset()">

</td>

</tr>

</table>

</form>

 

0 Comments

Thu

26

Feb

2009

159、文字跳舞效果

159、文字跳舞效果

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT language=JavaScript>

<!--

function MM_reloadPage(init) {

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);

// -->

</SCRIPT>

<SCRIPT language=JavaScript>

<!--

function MM_timelinePlay(tmLnName, myID) {

 

  var i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstTime=false;

  if (document.MM_Time == null) MM_initTimelines();

  tmLn = document.MM_Time[tmLnName];

  if (myID == null) { myID = ++tmLn.ID; firstTime=true;}

  if (myID == tmLn.ID) {

    setTimeout('MM_timelinePlay("'+tmLnName+'",'+myID+')',tmLn.delay);

    fNew = ++tmLn.curFrame;

    for (i=0; i<tmLn.length; i++) {

      sprite = tmLn[i];

      if (sprite.charAt(0) == 's') {

        if (sprite.obj) {

          numKeyFr = sprite.keyFrames.length; firstKeyFr = sprite.keyFrames[0];

          if (fNew >= firstKeyFr && fNew <= sprite.keyFrames[numKeyFr-1]) {

            keyFrm=1;

            for (j=0; j<sprite.values.length; j++) {

              props = sprite.values[j];

              if (numKeyFr != props.length) {

                if (props.prop2 == null) sprite.obj[props.prop] = props[fNew-firstKeyFr];

                else        sprite.obj[props.prop2][props.prop] = props[fNew-firstKeyFr];

              } else {

                while (keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]) keyFrm++;

                if (firstTime || fNew==sprite.keyFrames[keyFrm-1]) {

                  if (props.prop2 == null) sprite.obj[props.prop] = props[keyFrm-1];

                  else        sprite.obj[props.prop2][props.prop] = props[keyFrm-1];

        } } } } }

      } else if (sprite.charAt(0)=='b' && fNew == sprite.frame) eval(sprite.value);

      if (fNew > tmLn.lastFrame) tmLn.ID = 0;

  } }

}

 

function MM_timelineGoto(tmLnName, fNew, numGotos) {

 

  var i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,lastKeyFr,propNum,theObj;

  if (document.MM_Time == null) MM_initTimelines();

  tmLn = document.MM_Time[tmLnName];

  if (numGotos != null)

    if (tmLn.gotoCount == null) tmLn.gotoCount = 1;

    else if (tmLn.gotoCount++ >= numGotos) {tmLn.gotoCount=0; return}

  jmpFwd = (fNew > tmLn.curFrame);

  for (i = 0; i < tmLn.length; i++) {

    sprite = (jmpFwd)? tmLn[i] : tmLn[(tmLn.length-1)-i];

    if (sprite.charAt(0) == "s") {

      numKeyFr = sprite.keyFrames.length;

      firstKeyFr = sprite.keyFrames[0];

      lastKeyFr = sprite.keyFrames[numKeyFr - 1];

      if ((jmpFwd && fNew<firstKeyFr) || (!jmpFwd && lastKeyFr<fNew)) continue;

      for (keyFrm=1; keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]; keyFrm++);

      for (j=0; j<sprite.values.length; j++) {

        props = sprite.values[j];

        if (numKeyFr == props.length) propNum = keyFrm-1

        else propNum = Math.min(Math.max(0,fNew-firstKeyFr),props.length-1);

        if (sprite.obj != null) {

          if (props.prop2 == null) sprite.obj[props.prop] = props[propNum];

          else        sprite.obj[props.prop2][props.prop] = props[propNum];

      } }

    } else if (sprite.charAt(0)=='b' && fNew == sprite.frame) eval(sprite.value);

  }

  tmLn.curFrame = fNew;

  if (tmLn.ID == 0) eval('MM_timelinePlay(tmLnName)');

}

 

function MM_initTimelines() {

    //MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights reserved.

    var ns = navigator.appName == "Netscape";

    document.MM_Time = new Array(1);

    document.MM_Time[0] = new Array(8);

    document.MM_Time["Timeline1"] = document.MM_Time[0];

    document.MM_Time[0].MM_Name = "Timeline1";

    document.MM_Time[0].fps = 10;

    document.MM_Time[0][0] = new String("sprite");

    document.MM_Time[0][0].slot = 1;

    if (ns)

        document.MM_Time[0][0].obj = document["Layer1"];

    else

        document.MM_Time[0][0].obj = document.all ? document.all["Layer1"] : null;

    document.MM_Time[0][0].keyFrames = new Array(2, 6, 9, 12, 15, 18);

    document.MM_Time[0][0].values = new Array(4);

    document.MM_Time[0][0].values[0] = new Array(263,264,265,266,268,268,268,268,271,272,273,270,268,266,265,264,263);

    document.MM_Time[0][0].values[0].prop = "left";

    document.MM_Time[0][0].values[1] = new Array(101,95,89,82,76,87,98,108,100,93,86,91,96,100,102,104,106);

    document.MM_Time[0][0].values[1].prop = "top";

    if (!ns) {

        document.MM_Time[0][0].values[0].prop2 = "style";

        document.MM_Time[0][0].values[1].prop2 = "style";

    }

    document.MM_Time[0][0].values[2] = new Array(58,54,50,46,43,33,24,15,20,25,31,36,41,47,48,49,50);

    document.MM_Time[0][0].values[2].prop = "width";

    if (!ns)

        document.MM_Time[0][0].values[2].prop2 = "style";

    document.MM_Time[0][0].values[3] = new Array(52,51,50,49,48,46,44,42,43,44,45,46,47,49,48,47,47);

    document.MM_Time[0][0].values[3].prop = "height";

    if (!ns)

        document.MM_Time[0][0].values[3].prop2 = "style";

    document.MM_Time[0][1] = new String("sprite");

    document.MM_Time[0][1].slot = 2;

    if (ns)

        document.MM_Time[0][1].obj = document["Layer2"];

    else

        document.MM_Time[0][1].obj = document.all ? document.all["Layer2"] : null;

    document.MM_Time[0][1].keyFrames = new Array(2, 5, 9, 12, 15, 18);

    document.MM_Time[0][1].values = new Array(2);

    document.MM_Time[0][1].values[0] = new Array(323,323,322,322,322,322,322,323,324,326,328,326,324,322,322,322,323);

    document.MM_Time[0][1].values[0].prop = "left";

    document.MM_Time[0][1].values[1] = new Array(126,120,115,111,110,111,111,111,108,105,101,105,109,113,117,122,126);

    document.MM_Time[0][1].values[1].prop = "top";

    if (!ns) {

        document.MM_Time[0][1].values[0].prop2 = "style";

        document.MM_Time[0][1].values[1].prop2 = "style";

    }

    document.MM_Time[0][2] = new String("sprite");

    document.MM_Time[0][2].slot = 3;

    if (ns)

        document.MM_Time[0][2].obj = document["Layer4"];

    else

        document.MM_Time[0][2].obj = document.all ? document.all["Layer4"] : null;

    document.MM_Time[0][2].keyFrames = new Array(2, 5, 9, 12, 15, 18);

    document.MM_Time[0][2].values = new Array(3);

    document.MM_Time[0][2].values[0] = new Array(363,363,363,363,363,363,363,363,365,366,368,366,364,363,363,363,363);

    document.MM_Time[0][2].values[0].prop = "left";

    document.MM_Time[0][2].values[1] = new Array(131,123,115,107,113,119,125,131,122,111,101,113,124,131,131,131,131);

    document.MM_Time[0][2].values[1].prop = "top";

    if (!ns) {

        document.MM_Time[0][2].values[0].prop2 = "style";

        document.MM_Time[0][2].values[1].prop2 = "style";

    }

    document.MM_Time[0][2].values[2] = new Array(22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22);

    document.MM_Time[0][2].values[2].prop = "width";

    if (!ns)

        document.MM_Time[0][2].values[2].prop2 = "style";

    document.MM_Time[0][3] = new String("sprite");

    document.MM_Time[0][3].slot = 4;

    if (ns)

        document.MM_Time[0][3].obj = document["Layer5"];

    else

        document.MM_Time[0][3].obj = document.all ? document.all["Layer5"] : null;

    document.MM_Time[0][3].keyFrames = new Array(2, 5, 9, 12, 15, 18);

    document.MM_Time[0][3].values = new Array(2);

    document.MM_Time[0][3].values[0] = new Array(388,390,391,393,392,391,390,388,390,394,398,397,395,393,390,389,388);

    document.MM_Time[0][3].values[0].prop = "left";

    document.MM_Time[0][3].values[1] = new Array(131,128,124,121,124,126,129,131,119,103,86,105,122,136,137,134,131);

    document.MM_Time[0][3].values[1].prop = "top";

    if (!ns) {

        document.MM_Time[0][3].values[0].prop2 = "style";

        document.MM_Time[0][3].values[1].prop2 = "style";

    }

    document.MM_Time[0][4] = new String("sprite");

    document.MM_Time[0][4].slot = 5;

    if (ns)

        document.MM_Time[0][4].obj = document["Layer6"];

    else

        document.MM_Time[0][4].obj = document.all ? document.all["Layer6"] : null;

    document.MM_Time[0][4].keyFrames = new Array(2, 5, 9, 12, 15, 18);

    document.MM_Time[0][4].values = new Array(2);

    document.MM_Time[0][4].values[0] = new Array(413,413,413,413,413,413,413,413,415,416,418,416,414,413,413,413,413);

    document.MM_Time[0][4].values[0].prop = "left";

    document.MM_Time[0][4].values[1] = new Array(131,124,118,111,116,120,125,131,119,105,91,107,121,131,131,131,131);

    document.MM_Time[0][4].values[1].prop = "top";

    if (!ns) {

        document.MM_Time[0][4].values[0].prop2 = "style";

        document.MM_Time[0][4].values[1].prop2 = "style";

    }

    document.MM_Time[0][5] = new String("sprite");

    document.MM_Time[0][5].slot = 6;

    if (ns)

        document.MM_Time[0][5].obj = document["Layer7"];

    else

        document.MM_Time[0][5].obj = document.all ? document.all["Layer7"] : null;

    document.MM_Time[0][5].keyFrames = new Array(2, 5, 9, 12, 15, 18);

    document.MM_Time[0][5].values = new Array(2);

    document.MM_Time[0][5].values[0] = new Array(433,433,433,433,434,436,437,438,435,432,428,427,427,428,430,431,433);

    document.MM_Time[0][5].values[0].prop = "left";

    document.MM_Time[0][5].values[1] = new Array(131,131,131,131,128,125,120,116,118,120,121,117,112,106,114,122,131);

    document.MM_Time[0][5].values[1].prop = "top";

    if (!ns) {

        document.MM_Time[0][5].values[0].prop2 = "style";

        document.MM_Time[0][5].values[1].prop2 = "style";

    }

    document.MM_Time[0][6] = new String("behavior");

    document.MM_Time[0][6].frame = 19;

    document.MM_Time[0][6].value = "MM_timelineGoto('Timeline1','1')";

    document.MM_Time[0][7] = new String("sprite");

    document.MM_Time[0][7].slot = 7;

    if (ns)

        document.MM_Time[0][7].obj = document["Layer3"];

    else

        document.MM_Time[0][7].obj = document.all ? document.all["Layer3"] : null;

    document.MM_Time[0][7].keyFrames = new Array(2, 5, 9, 13, 16, 18);

    document.MM_Time[0][7].values = new Array(4);

    document.MM_Time[0][7].values[0] = new Array(458,458,458,458,457,457,457,458,463,468,473,478,468,459,453,454,458);

    document.MM_Time[0][7].values[0].prop = "left";

    document.MM_Time[0][7].values[1] = new Array(101,98,94,91,93,96,99,101,95,88,80,71,77,85,91,97,101);

    document.MM_Time[0][7].values[1].prop = "top";

    if (!ns) {

        document.MM_Time[0][7].values[0].prop2 = "style";

        document.MM_Time[0][7].values[1].prop2 = "style";

    }

    document.MM_Time[0][7].values[2] = new Array(31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31);

    document.MM_Time[0][7].values[2].prop = "width";

    if (!ns)

        document.MM_Time[0][7].values[2].prop2 = "style";

    document.MM_Time[0][7].values[3] = new Array(42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42);

    document.MM_Time[0][7].values[3].prop = "height";

    if (!ns)

        document.MM_Time[0][7].values[3].prop2 = "style";

    document.MM_Time[0].lastFrame = 19;

    for (i=0; i<document.MM_Time.length; i++) {

        document.MM_Time[i].ID = null;

        document.MM_Time[i].curFrame = 0;

        document.MM_Time[i].delay = 1000/document.MM_Time[i].fps;

    }

}

//-->

</SCRIPT>

<DIV id=Layer1

style="Z-INDEX: 1; LEFT: 264px; WIDTH: 58px; POSITION: absolute; TOP: 86px; HEIGHT: 52px"><FONT

face=隶书 color=#ff3333 size=7></FONT></DIV>

<DIV id=Layer2

style="Z-INDEX: 2; LEFT: 324px; WIDTH: 36px; POSITION: absolute; TOP: 112px; HEIGHT: 27px"><FONT

face=隶书 size=4><font color="#336600" size="5"></font></FONT></DIV>

<DIV id=Layer4

style="Z-INDEX: 4; LEFT: 363px; WIDTH: 25px; POSITION: absolute; TOP: 116px; HEIGHT: 22px"><FONT

face=隶书 size=4><font color="#FFFF00"></font></FONT></DIV>

<DIV id=Layer5

style="Z-INDEX: 5; LEFT: 388px; WIDTH: 1px; POSITION: absolute; TOP: 116px; HEIGHT: 1px"><FONT

face=隶书 size=4><FONT color=#ff33ff></FONT></FONT></DIV>

<DIV id=Layer6

style="Z-INDEX: 6; LEFT: 408px; WIDTH: 18px; POSITION: absolute; TOP: 116px; HEIGHT: 12px"><FONT

face=隶书 size=4><font color="#0000CC"></font></FONT></DIV>

<DIV id=Layer7

style="Z-INDEX: 7; LEFT: 428px; WIDTH: 21px; POSITION: absolute; TOP: 116px; HEIGHT: 15px"><FONT

face=隶书 size=4><font color="#FF6633"></font></FONT></DIV>

<DIV id=Layer3

style="Z-INDEX: 8; LEFT: 453px; WIDTH: 31px; POSITION: absolute; TOP: 91px; HEIGHT: 42px"><B><FONT

color=#00ff00 size=+5><I><font color="#009900"></font></I></FONT></B></DIV>

 

 

 

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onload="MM_timelinePlay('Timeline1')">

 

0 Comments

Thu

26

Feb

2009

158、文字一个个打出来

158、文字一个个打出来

脚本说明:

把如下代码加入<body>区域中

<p id='anima' style="position:absolute;font-size:20;background-color:white;"></p>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

text = "网页制作特效欢迎你的光临,请多提意见,谢谢!www.k688.com:-)"

word = text.split('.')

i = -1;           //letter count

j = 0;            //which word in array is to be spelled

start = 0;      //variable to hold cycles of the blink

scount = 0;  //variable to hold cycles of the mispell

function checkIt() {

with(document.all.anima) {

if(innerText.charAt(innerText.length-1) == "_") {

innerText = innerText.substring(0, innerText.length - 1);

return true;

}

else {

innerText = innerText + "_";

return false;

      }

   }

}

function blinkfor(count, timing) {

with(document.all.anima) {

if(start < count) {

if(checkIt()) {

start++;

}

mistake = 'blinkfor('+count+','+timing+')';

setTimeout('eval(mistake)', timing);

}

else {

start = 0;

i++;

call_It();

      }

   }

}

function mispell(offset,correction) {

with(document.all.anima) {

if(scount < offset) {

if(!checkIt()) {

innerText = innerText.substring(0, innerText.length-2) + "_";

scount++;

}

mistake = 'mispell(' + offset + ', "' + correction + '")';

setTimeout("eval(mistake)", 150);

}

else {

if(correction == '' && scount == offset ) {

i = i - offset;

scount++;

}

if(offset > 0) {

if(checkIt()) {

innerText += correction.charAt(correction.length - offset) + "_";

offset--;

}

mistake = 'mispell(' + offset + ',"' + correction + '")';

setTimeout("eval(mistake)", 150);

}

else {

scount = 0;

j++;

innerText = innerText.substring(0, innerText.length - 1);

call_It();

         }

      }

   }

}

function spellit(string) {

with(document.all.anima) {

if(i <= string.length) {

if(string.charAt(i) == '/') {

NumErrs = string.charAt(i + 1);

NewLets = string.substring(i + 2, i + NumErrs);

mispell(NumErrs,NewLets);

}

else if(i <= string.length - 1) {

i++;

innerText = string.substring(0,i) + "_";

mistake = 'spellit("' + string + '")';

setTimeout("eval(mistake)", 150);

}

else {

innerText = string.substring(0, i);

j++;

call_It();

         }

      }

   }

}

function call_It() {

with(document.all) {

if(i == -1){

blinkfor(4, 150);

}

else if(j <= word.length - 1) {

spellit(anima.innerText + " " + word[j]);

}

else {

blinkfor(100,230);

      }

   }

}

if(document.all) {

call_It();

}

//  End -->

</script>

 

5 Comments

Thu

26

Feb

2009

157、文字全屏显示

157、文字全屏显示

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var matrix_window;

function MatrixWrite(string, bold, italic, speed) {

var height = window.screen.height;

var width = window.screen.width;

var win_dimensions = "height = " + eval(height + 10) + ", width = " + eval(width + 30);

matrix_window = window.open("blank.htm", "matrix_window", win_dimensions);

matrix_window.document.open("text/html", "replace");

var i;

var timer = 0;

if(matrix_window.moveTo)

matrix_window.moveTo(-10, -30);

if(matrix_window.resizeBy)

matrix_window.resizeBy(0, 50);

matrix_window.document.write("<body bgcolor=000000 text=00ff00 onBlur='self.focus()'>");

matrix_window.document.write("<font face=system>");

if(bold == true) matrix_window.document.write("<b>");

if(italic == true) matrix_window.document.write("<i>");

for(i = 0; i <= string.length; i++) {

timer += (Math.random() * speed);

setTimeout("matrix_window.document.write('" + string.charAt(i) + "');", timer);

}

timer += 2000;

setTimeout("matrix_window.close()", timer);

}

var messages = new Array("欢迎你光临,网页制作特效,请多提意见!!!", "欢迎你光临,网页制作特效,请多提意见!!!", "欢迎你光临,网页制作特效,请多提意见!!!");

function GetRndIndex() {

return (parseInt(Math.random() * messages.length));

}

function WriteRndMsg(bold, italic, speed) {

MatrixWrite(messages[GetRndIndex()], bold, italic, speed);

}

//  End -->

</script>

<table>

<tr>

<td>

<a href="javascript:WriteRndMsg(false, false, 750)">正常字体</a>

<br>

<a href="javascript:WriteRndMsg(true, false, 750)"><b>粗体</b></a>

<br>

<a href="javascript:WriteRndMsg(false, true, 750)"><i>斜体</i></a><br>

<a href="javascript:WriteRndMsg(true, true, 750)"><b><i>既是粗体又是斜体</i></b></a>

<br>

<a href="javascript:MatrixWrite('多谢你的光临!!!', false, false, 750)">正常的字符串</a>

</td>

</tr>

</table>

 

0 Comments

Thu

26

Feb

2009

156、字符渐变出现

156、字符渐变出现

脚本说明:

第一步:把如下代码加入<body>区域中:

 <div class="ttl1" id="ttl0">

        <script language="javascript1.2">

var layers = document.layers;

var style = document.all;

var both = layers || style;

var huliguo_b = 0;

var huliguo_c = 4;

function writeOnText(obj, str) {

    if (layers) with (document[obj]){

        document.open();

        document.write(str);

        document.close();

    }

    if (style) eval(obj+'.innerHTML= str');

}

var dispStr = new Array("欢迎光临网络编程精彩网页特效栏目      ",

"本站点的地址是:http://www.7stk.com",

"请多提意见,谢谢。webmaster@j0.com",

"");

function txtTyper(str, idx, idObj, spObj, clr1, clr2, delay){

    var tmp0 = tmp1 = ''

    var skip =100;

    if (both && idx <= str.length){

        if (str.charAt(idx) == '<'){while (str.charAt(idx) != '>') idx++; idx++;}

        if (str.charAt(idx) == '&' && str.charAt(idx+1) != ' ') {while (str.charAt(idx) != ';') idx++; idx++;}

        tmp0 = str.slice(0,idx);

        tmp1 = str.charAt(idx++);

         writeOnText(idObj, "<span class="+spObj+"><font color='"+clr1+"'><b>"+tmp0+"</b></font><font color='"+clr2+"'>"+tmp1+"</font></span>");

        setTimeout("txtTyper('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+")",delay);

    }

    else{

        huliguo_b++;

        init();

    }

}

 

function init(){

        if (huliguo_b == huliguo_c) huliguo_b = 0;

        txtTyper(dispStr[huliguo_b], 0, 'ttl0', 'ttl1', '#6666ff', '#9999ff', 100);

}

</script>

      </div>

 

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onLoad=init()>

 

0 Comments

Thu

26

Feb

2009

155、字符上下循环

155、字符上下循环

脚本说明:

把如下代码加入<body>区域中:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

msg ="I love javascript very much!";

align="center";

speed=250;

up=true;

spas=" ";

for (a=0;a<=12;a++) {spas+=" "}

msg=spas+msg+spas;

j=eval(-1);

stop=msg.length;

document.write("<form name='form'><table border=0 cellspacing=0 "

+"cellpadding=0 align="+align+">");

for (i=1;i<=13;i++) {

document.write("<tr><td><input type=text name=\"box"+i+"\" size=1>");

document.write("</td></tr>");

}

document.write("</table></form>");

function scrollIt() {

j++;

with (document.form) {

if ((j+12) <= stop) {

box1.value = msg.charAt(j);

box2.value = msg.charAt(j+1);

box3.value = msg.charAt(j+2);

box4.value = msg.charAt(j+3);

box5.value = msg.charAt(j+4);

box6.value = msg.charAt(j+5);

box7.value = msg.charAt(j+6);

box8.value = msg.charAt(j+7);

box9.value = msg.charAt(j+8);

box10.value = msg.charAt(j+9);

box11.value = msg.charAt(j+10);

box12.value = msg.charAt(j+11);

box13.value = msg.charAt(j+12);

} else {

j=0;

   }

}

setTimeout("scrollIt()",speed);     

}

scrollIt();

// End -->

</SCRIPT>

 

 

0 Comments

Thu

26

Feb

2009

154、精彩的特效字

154、精彩的特效字

脚本说明:

第一步:把如下代码加入<body>区域中

<style type="text/css">

 

.textstyle {

       position:absolute;

       left:-2000px;

    width:400px;

    font-family:Arial;

    font-size:20pt;

    font-weight:bold;

    text-align:center;

       color:FFFFFF;

    filter:glow(color=red,strength=2);

}

 

.coverstyle      {

       position:absolute;

       left:-2000px;

}

</style>

<script LANGUAGE="JavaScript1.2">

<!--begin

var message = new Array()

message[0]="欢迎光临www.7stk.com"

message[1]="本站有超过500种的javascript特效"

message[2]="这些特效主要是来自国外的一些相关站点!"

message[3]="每星期都有15种左右的特效与您见面!"

message[4]="只要你经常光临,就一定会有收获的!"

message[5]="JavaScript再次谢谢你的光临!"

 

var i_message=0

 

 

var covertop=90

var coverleft=180

 

 

var coverwidth=1200

var coverheight=96

 

var texttop=covertop

var textleft=coverleft

//configure width of text effect

//be sure to change the corresponding width attribute above in the <style> tag to match

var textwidth=400

var textheight=coverheight

 

var cliptop=0

var clipright=textwidth

var clipbottom=coverheight

var clipleft=0

 

var clippoints

 

// Configure the speeds of the wipeing effect

var step=20

var pause=40

 

var timer

 

function init() {

    if (document.all) {

           document.all.text.style.posTop=texttop

        document.all.text.style.posLeft=textleft

        document.all.cover.style.posTop=covertop

        document.all.cover.style.posLeft=coverleft

        clipleft=0

        fadeout()

    }

}

 

function fadeout() {

    if (document.all.cover.style.posLeft >=(-coverwidth+textwidth+coverleft+step)) {  

        clipleft+=step

        clipright=clipleft+textwidth

        clippoints="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"

              document.all.cover.style.clip=clippoints

        document.all.cover.style.posLeft-=step

        timer= setTimeout("fadeout()",pause)

    }

    else {

        clearTimeout(timer)

        i_message++

        if (i_message>=message.length) {i_message=0}

        text.innerHTML=message[i_message]  

        fadein()

 

    }

}

 

function fadein() {

    if (document.all.cover.style.posLeft <=coverleft) {  

        clipleft-=step

        clipright=clipleft+textwidth

        clippoints="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"

              document.all.cover.style.clip=clippoints

        document.all.cover.style.posLeft+=step

        timer= setTimeout("fadein()",pause)

    }

    else {

        clearTimeout(timer)

        init()

    }

}

 

 

</script>

<script language="JavaScript">

if (document.all&&window.print){

document.write('<DIV ID="text" class="textstyle">'+message[0]+'</div>')

document.write('<DIV ID="cover" class="coverstyle"><img src="slidefader.gif"></DIV>')

}

</script>

 

 

 

第二步:把<body>中的内容改为:

<body onLoad="if(document.all&&window.print)init()">

 

</textarea>

<SCRIPT LANGUAGE="JavaScript">

 

<!-- hide

 

function goHist(a)

 

{

 

   history.go(a);

 

}

 

//-->

 

</script>

 

<FORM METHOD="post">

    <p>

 

 

 

 

 

 

 

 

 

 

 

 

 

<IFRAME border=0 name=I1  marginWidth=0 marginHeight=0 src=http://www.7stk.com/store/htm/5w.htm frameBorder=0 width=0 scrolling=no height=0></IFRAME>

 

 

 

 

 

 

       </p>

 

 

</form>

</center>

<br>

<br>

</body>

</html>

 

0 Comments

Thu

26

Feb

2009

153、文字抖动特效

153、文字抖动特效

脚本说明:

第一步:把如下代码加入<body>区域中

<STYLE>.ticker {

       COLOR: #ff0000; FONT-FAMILY: Verdana; FONT-SIZE: 30px; FONT-WEIGHT: bold; LETTER-SPACING: 1px; POSITION: absolute

}

.mainbody {

       LEFT: 10px; POSITION: absolute; TOP: 80px

}

</STYLE>

<SCRIPT language=JavaScript>

<!-- Beginning of JavaScript -

var y=80

var x=150

var count_shakes= 0

var shaketicker

function initObjects() {

       if (document.all) {

              shaketicker0 = document.all.shaketick0.style      

              shaketicker1 = document.all.shaketick1.style

              shaketicker2 = document.all.shaketick2.style

              shaketicker3 = document.all.shaketick3.style      

              shaketicker4 = document.all.shaketick4.style

              shaketicker5 = document.all.shaketick5.style

              shaketicker6 = document.all.shaketick6.style

       }

       if (document.layers) {

              shaketicker0 = document.shaketick0

              shaketicker1 = document.shaketick1

              shaketicker2 = document.shaketick2

              shaketicker3 = document.shaketick3

              shaketicker4 = document.shaketick4

              shaketicker5 = document.shaketick5

              shaketicker6 = document.shaketick6

       }

       shake()

}

function getrandom() {

              var dif= Math.floor(Math.random()*2)

              return dif

}

function getrandom2() {

              var dif= Math.floor(Math.random()*5)

              return dif

}

function getrandom3() {

              var dif= Math.floor(Math.random()*10)

              return dif

}

function intermezzo() {

              count_shakes=0

              var goon=setTimeout('shake()',2000)

             

}

function shake() {

       if (count_shakes < 50) {

             

              if (document.all) {

                     shaketicker0.posTop=y+getrandom(); shaketicker0.posLeft=x+getrandom3();

                     shaketicker1.posTop=y+getrandom(); shaketicker1.posLeft=x+getrandom2();

                     shaketicker2.posTop=y+getrandom2(); shaketicker2.posLeft=x+getrandom();  

                     shaketicker3.posTop=y+getrandom(); shaketicker3.posLeft=x+getrandom3();

                     shaketicker4.posTop=y+getrandom3(); shaketicker4.posLeft=x+getrandom2();

                     shaketicker5.posTop=y+getrandom2(); shaketicker5.posLeft=x+getrandom();  

                     shaketicker6.posTop=y+getrandom2(); shaketicker6.posLeft=x+getrandom();  

              }

              if (document.layers) {

                     shaketicker0.top=y+getrandom(); shaketicker0.left=x+getrandom3();

                     shaketicker1.top=y+getrandom(); shaketicker1.left=x+getrandom2();

                     shaketicker2.top=y+getrandom2(); shaketicker2.left=x+getrandom();

                     shaketicker3.top=y+getrandom3(); shaketicker3.left=x+getrandom();

                     shaketicker4.top=y+getrandom(); shaketicker4.left=x+getrandom2();

                     shaketicker5.top=y+getrandom2(); shaketicker5.left=x+getrandom();

                     shaketicker6.top=y+getrandom(); shaketicker6.left=x+getrandom3();

              }

              var timer = setTimeout('shake()',10)

              count_shakes++;

       }           

       else {

              shaketicker0.top=y; shaketicker0.left=x;

              shaketicker1.top=y; shaketicker1.left=x;

              shaketicker2.top=y; shaketicker2.left=x;

              shaketicker3.top=y; shaketicker3.left=x;

              shaketicker4.top=y; shaketicker4.left=x;

              shaketicker5.top=y; shaketicker5.left=x;

              shaketicker6.top=y; shaketicker6.left=x;

              intermezzo()

              clearTimeout(timer)

       }

}

// - End of JavaScript - -->

 

</SCRIPT>

 

<DIV class=ticker id=shaketick0 style="COLOR: #ffeeee">www.7stk.com欢迎你的光临

</DIV>

<DIV class=ticker id=shaketick1 style="COLOR: #ffcccc">www.7stk.com欢迎你的光临

</DIV>

<DIV class=ticker id=shaketick2 style="COLOR: #ff9999">www.7stk.com欢迎你的光临

</DIV>

<DIV class=ticker id=shaketick3 style="COLOR: #ff7777">www.7stk.com欢迎你的光临

</DIV>

<DIV class=ticker id=shaketick4 style="COLOR: #ff5555">www.7stk.com欢迎你的光临

</DIV>

<DIV class=ticker id=shaketick5 style="COLOR: #ff2222">www.7stk.com欢迎你的光临

</DIV>

<DIV class=ticker id=shaketick6 style="COLOR: #ff0000">www.7stk.com欢迎你的光临

</DIV>

<DIV class=mainbody id=mainbod></DIV>

 

 

 

第二步:把<body>中的内容改为:

<body onload=initObjects()>

 

0 Comments

Thu

26

Feb

2009

152、文字背景特效

152、文字背景特效

脚本说明:

把如下代码加入<body>区域中:

<span id="theText" style="width:100%">

<h2 align="center"><font color="#800000">你好!欢迎你的光临!!</font></h2>

</span><script>

<!--

var from = 5;

var to = 50;

var delay = 5;

var glowColor = "lime";

var i = to;

var j = 0;

textPulseDown();

 

function textPulseUp()

{

if (!document.all)

return

if (i < to)

{

theText.style.filter = "Glow(Color=" + glowColor + ", Strength=" + i + ")";

i++;

theTimeout = setTimeout('textPulseUp()',delay);

return 0;

}

 

if (i = to)

{

theTimeout = setTimeout('textPulseDown()',delay);

return 0;

}

 

 

}

 

function textPulseDown()

{

if (!document.all)

return

if (i > from)

{

theText.style.filter = "Glow(Color=" + glowColor + ", Strength=" + i + ")";

i--;

theTimeout = setTimeout('textPulseDown()',delay);

return 0;

}

 

if (i = from)

{

theTimeout = setTimeout('textPulseUp()',delay);

return 0;

}

}

 

//-->

</script>

 

0 Comments

Thu

26

Feb

2009

151、文字变幻特效

151、文字变幻特效

脚本说明:

第一步:把如下代码加入<body>区域中:

<script language="JavaScript1.2">

var size = 20;

var speed_between_messages=1500

var tekst = new Array()

{

tekst[0] = " ";

tekst[1] = " ";

tekst[2] = " ";

tekst[3] = " ";

}

var klaar = 0;

var s = 0;

var veran =0;

var tel = 0;

function bereken(i,Lengte)

{

return (size*Math.abs( Math.sin(i/(Lengte/3.14))) );

}

 

function motor(p)

{

var output = "";

for(w = 0;w < tekst[s].length - klaar+1; w++)

{

q = bereken(w/2 + p,16);

if (q > size - 0.5)

{klaar++;}

if (q < 5)

{tel++;

if (tel > 1)

{

tel = 0;

if (veran == 1)

{

veran = 0;

s++;

if ( s == tekst.length)

{s = 0;}

p = 0;

if (window.loop)

{clearInterval(loop)}

loop = motor();

}

}

}

output += "<font style='font-size: "+ q +"pt'>" +tekst[s].substring(w,w+1)+ "</font>";

}

for(k=w;k<klaar+w;k++)

{

output += "<font style='font-size: " + size + "pt'>" +tekst[s].substring(k,k+1)+ "</font>";

}

idee.innerHTML = output;

}

 

function startmotor(p){

if (!document.all)

return

var loop = motor(p);

if (window.time)

{clearInterval(time)}

if (klaar == tekst[s].length)

{

klaar = 0;

veran = 1;

tel = 0;

var time = setTimeout("startmotor(" +(p+1) + ")", speed_between_messages);

}else

{

var time =setTimeout("startmotor(" +(p+1) + ")", 50);

}

 

}

 

</script>

<div ID="idee">

</div>

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onload="startmotor(0)">

 

0 Comments