zoukankan      html  css  js  c++  java
  • 我的第一个javascript网页作业

       1:  <html>
       2:  <title>    
       3:   
       4:  </title>
       5:      <body>
       6:       <style type="text/css">
       7:                  #block{
       8:                  background-color:green;
       9:                  font-size:9pt;
      10:                  padding:30px;
      11:                  color:white;
      12:                  100px;
      13:                  height:120px;
      14:                  position:absolute;
      15:                  }
      16:        </style>
      17:        <div id="block"></div>  
      18:        
      19:        <script>
      20:              function down(event){
      21:   
      22:                  var x = event.clientX;
      23:                  var y = event.clientY;  
      24:                  var oleft = document.getElementById('block').offsetLeft;
      25:                  var otop  = document.getElementById('block').offsetTop;
      26:                  offx = x - oleft;
      27:                  offy = y - otop;
      28:                   
      29:                  document.onmousemove = move;
      30:                  document.onmousemup  = up;
      31:                 
      32:              }  
      33:              function move(event){
      34:                  var x = event.clientX;
      35:                  var y = event.clientY;                
      36:                   
      37:                  document.getElementById('block').style.left = x - offx +'px';  
      38:                  document.getElementById('block').style.top  = y - offy +'px';
      39:                  
      40:                  document.onmouseup = up;
      41:              }  
      42:              function up(){
      43:                  document.onmouseup = null;
      44:                  document.onmousemove = null;
      45:              }
      46:              window.onload = function(){
      47:                  document.onmousedown = down;
      48:              }
      49:          </script>     
      50:        
      51:   
      52:      </body>
      53:      
      54:   
      55:  </html>
  • 相关阅读:
    RubyConf的podcast
    一篇很好的英语学习文章:一个孤独而封闭世界――英语口语
    新浪和搜狐的读书频道
    新想法:个性化的RSS
    代码搜索:Koders
    我看到的Web 2.0: 自组织的大众化参与
    土豆网的后舍男孩挺搞笑的
    可以给pdf加批注的软件VeryPDF PDF Editor
    张海迪写的描写英语学习经验的书《美丽的英语》
    Fowler出来推荐Rake了(基于Ruby的build工具)
  • 原文地址:https://www.cnblogs.com/ppazhang/p/3250500.html
Copyright © 2011-2022 走看看