javascript基础应用

1.文字的颜色不断的改变
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
     </head>
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
   <script language="javascript">
    var  kinds;
   function  textColor(){
      kinds=textColor.arguments.length;  //arguments.length可以获取对象的参数个数
	  for(var i=0;i<kinds;i++)
      { 
	      this[i] =textColor.arguments[i] ;
	  }	  
   }
   tmp=new textColor(
       "#ffff00",
       "#f4f4f4",
       "#fff000" ,
	   "#ff0000",
       "#f00000" 
   );
   document.writeln('<span id="test">fuchuanbi test hfut university</span>'+"<br>");
   var pos=0;
   function changeColor()
   { 
      if(pos < kinds)
	  {
        pos++;
	   }else{
	    pos= 0;
	   }
      document.getElementById("test").style.color=tmp[pos];
	  setTimeout("changeColor()",300);
   }
   </script>
  <body>
   <input type="button" οnclick="changeColor()" value="change()">
  </body>
</html>


2.字体大小写变换

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
     </head>
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	
   <script language="javascript">
    var  message="change from small to big and big to small";
	var  textsize=28;
	var  x=0 ;
	document.write('<span id="wps"></span><br>');
	function upwords(){
	  if(x < textsize){
	      x++ ;
	  setTimeout("upwords()",100);
	  }else{
	  setTimeout("downwords()",100);  
	  }
	  wps.innerHTML="<center>"+message+x+"</center>" ;
	  wps.style.fontSize=x+'px';
	}
	function downwords(){
	  if(x> 0){
	    x--;
		setTimeout("downwords()",100);
	  }else{
	     setTimeout("upwords()",100);
	  }
	 wps.innerHTML="<center>"+message+x+"</center>" ;
	 wps.style.fontSize=x+'px';
	}
	
   </script>
  <body OnLoad="upwords()">
  </body>
</html>


3.点击出现菜单栏

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
     </head>
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<style type="text/css">
	.box{
	  background:#996633 ;
	  font: 9px;
	  position:absolute;
	  border:1px solid #f4f4f4;
	}
	</style>
   <script language="javascript">
    document.οnclick=showMouseMove;//绑定点击事件

    function showMouseMove(){
    newX=window.event.x;
	newY=window.event.y; //获取到当前鼠标的位置
     if(document.getElementById("test").style.display=="")
	 {
        document.getElementById("test").style.display="none" ;
	 }else{
	    document.getElementById("test").style.display=""  ;
		}
       document.getElementById("test").style.pixelLeft=newX-50;
       document.getElementById("test").style.pixelTop=newY-50;	   
	 } 
   </script>
  <body >
  <table id="test" class="box" style="display :none " height="101" width="80">
    <tr>fuChuanBi</tr>
    <tr>YangxuRui</tr>	
  </table>
  </body>
</html>

4.跑马灯

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>?????</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
   <script language="javascript">
    var id,pause=0,position=0;
	function banner(){
	   var i,k;
	   var m1="       welcome to myhome for learning JavaScript";
	   var m2="       Object to develop";
	   var msg=m1+m2 ;
	   var speed=10;
	   document.iform.banner.value=msg.substring(position,position+160);
	    document.iform.pos.value=position;
	   if(position++==msg.length){
	   position=0;
	   }
	   id=setTimeout("banner()",2000/speed);
	}
   </script>
  </head>
  
  <body onLoad="banner()">
  <form method="post" name="iform">
  <input type="text" size="48" maxlength="256" name="banner">
  <input type="text" size="48" maxlength="256" name="pos">
  </form>
    This is my HTML page. <br>
  </body>
</html>


5.使用marquee 设置滚动导航条

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
     </head>
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<style type="text/css">
	.box{
	  background:#996633 ;
	  font: 9px;
	  position:absolute;
	  border:1px solid #f4f4f4;
	}
	</style>
   <script language="javascript">
      var link= new Array("fuchuanbi","YxiaoRui","hfut_xiaobi");
	  var addr=new Array("www.baidu.com","www.163.com","www.unversity.edu.cn");
	  document.write("<marquee scrollamount=1 direction=up width=150 height=60>");
	  for(var i=0;i<link.length;i++)
	  {
	    document.write("<a href="+addr[i]+">"+link[i]+"</a><br>");
	  }
	  document.write("</marquee>");
   </script>
  <body >
  <table id="test" class="box" style="display :none " height="101" width="80">
    <tr>fuChuanBi</tr>
    <tr>YangxuRui</tr>	
  </table>
  </body>
</html>

6.文字的上下移动

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
     </head>
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	
   <script language="javascript">
   var pos= -50;
   function upwords(){
      if(pos >50){
	     setTimeout("downwords()",20);
	  }else{
	     pos++;
		 setTimeout("upwords()",20);
	  }
      document.getElementById("t1").style.top=pos;
   }
   function downwords(){
     if(pos < -50){
	    setTimeout("upwords()",20);
	 }else{
	   pos --;
	   setTimeout("downwords()",20);
	 }
    document.getElementById("t1").style.top=pos;
   }
   
     setTimeout("upwords()",20);
   </script>
  <body >
   <span id="t1" style="position:absolute ;top: -50; font-size:9px;">it is mine</span>
  </body>
</html>



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值