183、可调节的输出形式

183、可调节的输出形式

脚本说明:

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

 <SCRIPT>

 

 var msg = "javascript欢迎你的光临!!!"

 

 var x = ""

 

 num = 1

 

 toggle = 1

 

 tt = 1

 

 OOK = 0

 

 timval = 60

 

 var tval = ""

 

 function switcha() {

 

    if (document.myform.dowhat.value == "Start/Stop" )

 

      tval = "Forward/Backward"

 

    if (document.myform.dowhat.value == "Forward/Backward")

 

      tval = "Fast/Slow"

 

    if (document.myform.dowhat.value == "Fast/Slow")

 

      tval = "Start/Stop"

 

    document.myform.dowhat.value = tval

 

 }

 

 function switcha2() {

 

    if (document.myform.dowhat.value == "Start/Stop" ) toggla()

 

    if (document.myform.dowhat.value == "Forward/Backward" ) csd()

 

    if (document.myform.dowhat.value == "Fast/Slow" ) fasl()

 

 }

 

 function fasl() { timval = (timval==60 ? 150 : 60 ) }

 

 

 

 function csd() {

 

    tt = ( tt==1 ? 0 : 1)

 

 }

 

 function scroll() {

 

   if (tt==1)

 

     if (num <= msg.length)

 

       OOK = 1

 

   if (tt==0)

 

     if (num >= 0)

 

       OOK = 1

 

 

 

   if ( OOK == 1)

 

  {

 

  OOK = 0

 

  x = msg.substring(0,num)

 

  document.myform.scroll.value = x

 

  num = ( tt==1 ? num+1 : num-1 )

 

  }

 

   else

 

  {

 

  x = ""

 

  document.myform.scroll.value = ""

 

  num = (tt==1 ? 0 : msg.length )

 

  }

 

   if (toggle == 1)

 

  setTimeout("scroll()", timval)

 

 }

 

 function toggla() {

 

  toggle = (toggle == 1 ? 0 : 1 )

 

  if (toggle == 1) scroll()

 

 }

 

 

 

 </SCRIPT>

 <FORM NAME="myform">

 <INPUT TYPE="text" NAME="scroll" SIZE=&{msg.length + 2}; ><br>

 <INPUT TYPE="button"  VALUE="Do It" onClick="switcha2()">

 <INPUT TYPE="text" NAME="dowhat" SIZE = 10 VALUE = "Start/Stop">

 <INPUT TYPE="button" VALUE="next" onClick="switcha()" >

 </FORM>

 

 

 

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

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

 

Write a comment

Comments: 0