zoukankan      html  css  js  c++  java
  • Day9--------windowDrag

     //-----------使用嵌套的事件完成窗口的拖拉效果
    1
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title></title> 6 </head> 7 <style type="text/css"> 8 #window{ 200px;height: 100px;position: absolute; 660px;height: 360px;} 9 #head{height: 20px; 660px;background: #BBB;} 10 </style> 11 <script type="text/javascript"> 12 window.onload=function(){ 13 var tecentX=0; 14 var tecentY=0; 15 var oHead=document.getElementById('head'); 16 var oWindow=document.getElementById('window') 17 oHead.onmousedown=function(ev){ 18 var oEvent=ev||event; 19 tecentX=oEvent.clientX-oWindow.offsetLeft; 20 tecentY=oEvent.clientY-oWindow.offsetTop; 21 document.onmousemove=function(ev){ 22 var oEvent=ev||event; 23 oWindow.style.left=oEvent.clientX-tecentX+'px'; 24 oWindow.style.top=oEvent.clientY-tecentY+'px'; 25 } 26 document.onmouseup=function(){ 27 document.onmousemove=null; 28 document.onmouseup=null; 29 } 30 return false; 31 } 32 } 33 </script> 34 <body> 35 <div id="window"><div id="head"></div><embed src="file/toyou.swf" width="660px" height="340px" /></div> 36 </body> 37 </html>
  • 相关阅读:
    sql知识点记录
    makefile编译错误情况整理
    web worker 简介
    实现跨域访问的方法总结
    fiddler使用指南
    [转]SASS用法指南
    koa文档参考
    [转]html5: postMessage解决跨域和跨页面通信的问题
    [转]JavaScript ES6 class指南
    [转]前端利器:SASS基础与Compass入门
  • 原文地址:https://www.cnblogs.com/fleshy/p/4129228.html
Copyright © 2011-2022 走看看