Chinaunix首页 | 论坛 | 博客
  • 博客访问: 240691
  • 博文数量: 108
  • 博客积分: 3045
  • 博客等级: 中校
  • 技术积分: 1162
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-19 18:26
文章分类

全部博文(108)

分类: JavaScript

2013-11-28 13:22:17


点击(此处)折叠或打开

  1. //test.html

  2. <frameset rows="100,*">
  3.     <frame name="top"/>
  4.     <frameset cols="150,*">
  5.         <frame name="menu" src="menu.html"/>
  6.         <frame name="main"/>
  7.     </frameset>
  8. </frameset>

  9. //menu.html
  10. <input type="button" onclick="window.document.bgColor='yellow'" value="改自己的"><br>
  11. <input type="button" onclick="window.parent.parent.frames[0].document.bgColor='green'" value="改上面的"><br>
  12. <input type="button" onclick="window.top.frames['main'].document.bgColor='red'" value="改右面的"><br>


点击(此处)折叠或打开

  1. <body>
  2.     <script type="text/javascript" charset="utf-8">
  3.         var subwin=window.open("win.html","_blank","top=300,left=300,width=200,height=200")

  4.         function show(obj){
  5.             //window.document.bgColor=obj.value;
  6.             subwin.documnet.bgColor=obj.value;
  7.         }
  8.     </script>

  9.     <input type="button" onclick="show(this)" value="red"><br>
  10.     <input type="button" onclick="show(this)" value="green"><br>
  11.     <input type="button" onclick="show(this)" value="yellow"><br>
  12.     <input type="button" onclick="show(this)" value="blue"><br>
  13.     <input type="button" onclick="show(this)" value="#ffooff"><br>
  14. </body>


点击(此处)折叠或打开

  1. <body>
  2.     <script type="text/javascript" charset="utf-8">
  3.         var one=setTimeout(function(){
  4.             document.bgColor="red";
  5.                 },3000);
  6.         var two=setTimeout(function(){
  7.             document.bgColor="blue";

  8.                 },6000);
  9.         var three=setTimeout(function(){
  10.             document.bgColor="green";
  11.                 },9000);

  12.         function stop(){
  13.             clearTimeout(two);
  14.         }
  15.     </script>

  16.             <input type="button" onclick="stop()" value="add">
  17. </body>


点击(此处)折叠或打开

  1. <!--setInterval用法 -->
  2. <body>
  3.     <div id="one" style="position:absolute;left:0;top:p;width:100px;height:100px;background:red;">
  4.         嗯,是的,
  5.     </div>

  6.     <script>
  7.         var x=0;
  8.         var y=0;

  9.         var xs=10;
  10.         var ys=10;
  11.         
  12.         var one=document.getElementById("one");

  13. //        alert (window.document.body.clientWidth);
  14.         function move(){
  15.             x+=xs;
  16.             y+=ys;
  17.             if (x >= document.body.clientWidth-one.offsetWidth || x <= 0){
  18.                 xs=-1*xs;
  19.             }
  20.             if (y >= document.body.clientHeigth-one.offsetHeight || y <= 0){
  21.                 ys=-1*ys;
  22.             }
  23.             one.style.left=x;
  24.             one.style.top=y;
  25.         }
  26.         setInterval("move()",100);

  27.         one.onmouseover=function(){
  28.             clearInterval(dt);
  29.         }
  30.         one.onmouseout=function(){
  31.             dt=setInterval("move()",100);
  32.         }
  33.     </script>
  34. </body>

阅读(349) | 评论(0) | 转发(0) |
0

上一篇:js_事件对象_2

下一篇:js_dom_2

给主人留下些什么吧!~~