资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
兼容ie ff div 层 打开+关闭+ 拖动+遮罩+移动+动画改变高宽
1 拖动+遮罩+移动+改变元素大小
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>popper.w's code</title> <style type="text/css"> body{text-align:center} #dd{ margin:50px auto} #odiv{ width:400px; height:200px;border:1px dotted red; border:1px dashed green;} #odiv ul{ list-style:none; text-align:left; width:150px; font-size:11px;} #odiv ul li{height:25px; line-height:25px; border-bottom:1px dashed green;} #ho{ width:150px; height:150px; border:1px dotted red} </style> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%20%3E%20%0D%0Afunction%20%24%20(o)%20%7B%20%0D%0A%20%20%20%20%20%20return%20document.getElementById(o)%3B%20%0D%0A%7D%20%0D%0Afunction%20XCreateElement(tagName%2CtagParent%2Cattrs)%20%0D%0A%7B%20%0D%0A%20%20%20%20if(tagName%26%26arguments.length%3C2)%7BtagParent%3Ddocument.body%3B%7D%20%0D%0A%20%20%20%20%20%20%20%20var%20oTemp%3Ddocument.createElement(tagName)%3B%20%0D%0A%20%20%20%20%20%20%20%20if(attrs%26%26attrs.constructor%3D%3DObject)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20for(var%20o%20in%20attrs)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20oTemp.setAttribute(o%2Cattrs%5Bo%5D)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20tagParent.appendChild(oTemp)%3B%20%0D%0A%20%20%20%20%20%20%20%20return%20oTemp%3B%20%0D%0A%7D%20%0D%0Afunction%20XSetCss(obj%2CcssArgs)%7B%20%0D%0A%20%20%20%20if(arguments.length%3D%3D2)%20%0D%0A%20%20%20%20%7B%20%20%0D%0A%20%20%20%20if(cssArgs.constructor%3D%3DObject)%7B%20%0D%0A%20%20%20%20for(var%20o%20in%20cssArgs)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(obj.style%5Bo%5D!%3D%22undefiend%22)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj.style%5Bo%5D%3DcssArgs%5Bo%5D%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20if(cssArgs.constructor%3D%3DArray%26%26cssArgs.length%3D%3D2)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj.style%5BcssArgs%5B0%5D%5D%3DcssArgs%5B1%5D%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%0D%0A%20%20%20%20%7D%20%0D%0A%20%20%20%20%7D%20%0D%0A%7D%20%0D%0Afunction%20XslideUp(obj%2Ctype%2CmX%2Cnum)%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(!type)%7Breturn%3B%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20try%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CXgetOffset(obj)%5Btype%5D-num%2B%22px%22%5D)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24(%22aa%22).innerHTML%3DXgetOffset(obj)%5Btype%5D%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(XgetOffset(obj)%5Btype%5D%3EmX)%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20setTimeout(function()%7BXslideUp(obj%2Ctype%2CmX%2Cnum)%3B%7D%2C1)%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CmX%5D)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20catch(e)%7B%7D%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0Afunction%20XslideDown(obj%2Ctype%2CmX%2Cnum)%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(!type)%7Breturn%3B%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20try%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CXgetOffset(obj)%5Btype%5D%2Bnum%2B%22px%22%5D)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24(%22aa%22).innerHTML%3DXgetOffset(obj)%5Btype%5D%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(XgetOffset(obj)%5Btype%5D%3CmX)%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20setTimeout(function()%7BXslideDown(obj%2Ctype%2CmX%2Cnum)%3B%7D%2C1)%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CmX%5D)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20catch(e)%7B%7D%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0Afunction%20XgetOffset%20(obj)%20%7B%20%0D%0A%20%20%20%20%20%20%20%20return%20%7Bheight%3Aobj.offsetHeight%2Cwidth%3Aobj.offsetWidth%7D%20%0D%0A%7D%20%0D%0A%2F*%E7%A7%BB%E5%8A%A8%E5%87%BD%E6%95%B0*%2F%20%0D%0A%2F*o%3Aelement%20%20%20l%3A%20left%20t%3Atop*%2F%20%0D%0Afunction%20Xmove(o%2Cl%2Ct)%7B%20%0D%0Ao.style.position%3D%22absolute%22%3B%20%0D%0Avar%20a%3D1%3B%20%0D%0Avar%20ol%3DparseInt(o.offsetLeft)%3B%20%0D%0Avar%20ot%3DparseInt(o.offsetTop)%3B%20%0D%0Avar%20iTimer%3DsetInterval(function()%7B%20%0D%0A%20%20%20if(a%3D%3D10)%20%0D%0A%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20Xtransp(o%2C%22end%22)%3B%20%0D%0A%20%20%20%20%20%20%20%20clearInterval(iTimer)%3B%20%0D%0A%20%20%20%20%7D%20%0D%0A%20%20%20o.style.left%3Dol%2Ba*(l-ol)%2F10%2B%22px%22%3B%20%0D%0A%20%20%20o.style.top%3Dot%2Ba*(t-ot)%2F10%2B%22px%22%3B%20%0D%0A%20%20%20a%2B%2B%3B%20%0D%0A%7D%2C20)%3B%20%0D%0A%7D%20%0D%0A%2F*%20%E5%8F%96%E6%B6%88%E4%BA%8B%E4%BB%B6%E5%86%92%E6%B3%A1*%2F%20%0D%0Afunction%20XcancleBubble(e)%20%0D%0A%7B%20%0D%0Avar%20e%20%3D%20window.event%20%7C%7C%20e%3B%20%0D%0Aif%20(e.preventDefault)%20e.preventDefault()%3B%20%0D%0Aelse%20e.returnValue%20%3D%20false%3B%20%0D%0A%7D%20%0D%0A%2F*%E8%AE%BE%E7%BD%AE%E9%80%8F%E6%98%8E%E5%BA%A6%E5%87%BD%E6%95%B0%20o%3A%20dom%20%E8%8A%82%E7%82%B9%20mode%3A%20start%3A%E8%AE%BE%E7%BD%AE%20%E5%BC%80%E5%A7%8B%20%20%20end%20%E8%AE%BE%E7%BD%AE%E7%BB%93%E6%9D%9F%20%2C%20num%3A%20%E9%80%8F%E6%98%8E%E5%BA%A6%201-100%20%E5%86%85%20%E6%95%B4%E6%95%B0*%2F%20%0D%0Afunction%20Xtransp(o%2Cmode%2Cnum)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20if(mode%3D%3D%22start%22)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(document.all)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20o.style.filter%20%3D%20%22Alpha(Opacity%3D%22%2Bnum%2B%22)%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7Delse%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20o.style.opacity%20%3D%20num%2F100%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20else%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(document.all)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20o.style.filter%20%3D%20%22Alpha(Opacity%3D100)%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7Delse%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20o.style.opacity%20%3D%201%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0A%7D%20%0D%0Afunction%20Xvisible(obj%2Cstart%2Cend%2Cstep%2Cinterval%2Ccallback)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20st%20%3D%20start%20%3E%20end%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%E6%AD%A5%E8%BF%9Bstart%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20st%20%3F%20start-%3Dstep%20%3A%20start%2B%3Dstep%3B%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%E5%BD%93start%E5%92%8Cend%E7%9A%84%E5%85%B3%E7%B3%BB%E5%8F%91%E7%94%9F%E5%8F%98%E5%8C%96%E6%97%B6%E5%81%9C%E6%AD%A2%E8%BF%90%E8%A1%8C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if((start%3Cend%20%5E%20st))%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj.style.filter%3D%22alpha(opacity%3D%22%2Bstart%2B%22)%22%3B%2F%2FIE%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj.style.MozOpacity%3Dstart%2F100%3B%2F%2FFF%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20catch(e)%7B%7D%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20setTimeout(function()%7Bvisible(obj%2Cstart%2Cend%2Cstep%2Cinterval%2Ccallback)%3B%7D%2Cinterval)%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%E6%89%A7%E8%A1%8C%E5%9B%9E%E8%B0%83%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20callback%20%3F%20callback()%20%3A%20%22%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0Avar%20XgetScroll%3Dfunction()%7B%20%0D%0A%20%20%20%20return%7Bheight%3Adocument.documentElement.scrollHeight%2Ctop%3Adocument.documentElement.scrollTop%7D%3B%20%0D%0A%7D%3B%20%0D%0Afunction%20getOffset(evt)%20%0D%0A%7B%20%0D%0Avar%20target%20%3D%20evt.target%3B%20%0D%0Aif%20(target.offsetLeft%20%3D%3D%20undefined)%20%0D%0A%7B%20%0D%0A%20%20%20%20target%20%3D%20target.parentNode%3B%20%0D%0A%7D%20%0D%0Avar%20pageCoord%20%3D%20getPageCoord(target)%3B%20%0D%0Avar%20eventCoord%20%3D%20%0D%0A%7B%20%0D%0A%20%20%20%20x%3A%20window.pageXOffset%20%2B%20evt.clientX%2C%20%0D%0A%20%20%20%20y%3A%20window.pageYOffset%20%2B%20evt.clientY%20%0D%0A%7D%3B%20%0D%0Avar%20offset%20%3D%20%0D%0A%7B%20%0D%0A%20%20%20%20offsetX%3A%20eventCoord.x%20-%20pageCoord.x%2C%20%0D%0A%20%20%20%20offsetY%3A%20eventCoord.y%20-%20pageCoord.y%20%0D%0A%7D%3B%20%0D%0Areturn%20offset%3B%20%0D%0A%7D%20%0D%0Afunction%20getPageCoord(element)%20%0D%0A%7B%20%0D%0Avar%20coord%20%3D%20%7Bx%3A%200%2C%20y%3A%200%7D%3B%20%0D%0Awhile%20(element)%20%0D%0A%7B%20%0D%0A%20%20%20%20coord.x%20%2B%3D%20element.offsetLeft%3B%20%0D%0A%20%20%20%20coord.y%20%2B%3D%20element.offsetTop%3B%20%0D%0A%20%20%20%20element%20%3D%20element.offsetParent%3B%20%0D%0A%7D%20%0D%0Areturn%20coord%3B%20%0D%0A%7D%20%0D%0Afunction%20getEventOffset(evt)%20%0D%0A%7B%20%0D%0Avar%20msg%20%3D%20%22%22%3B%20%0D%0Aif%20(evt.offsetX%20%3D%3D%20undefined)%20%0D%0A%7B%20%0D%0A%20%20%20%20var%20evtOffsets%20%3D%20getOffset(evt)%3B%20%0D%0A%20%20%20%20msg%3D%7BoffsetX%3AevtOffsets.offsetX%2CoffsetY%3AevtOffsets.offsetY%7D%3B%20%0D%0A%7D%20%0D%0Aelse%20%0D%0A%7B%20%0D%0A%20%20%20%20msg%3D%7BoffsetX%3Aevt.offsetX%2CoffsetY%3Aevt.offsetY%7D%3B%20%0D%0A%7D%20%0D%0Areturn%20msg%3B%20%0D%0A%7D%20%0D%0Afunction%20fDragStart(XEle)%20%0D%0A%7B%20%0D%0A%20%20%20%20switch(fCkBrs())%20%0D%0A%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20case%203%3A%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20window.getSelection().removeAllRanges()%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20default%3A%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20XEle.setCapture()%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%20%0D%0A%20%20%20%20%7D%20%0D%0A%7D%20%0D%0Afunction%20fDragEnd(XEle)%20%0D%0A%7B%20%0D%0A%20%20%20%20switch(fCkBrs())%20%0D%0A%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20case%203%3A%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20window.getSelection().removeAllRanges()%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20default%3A%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20XEle.releaseCapture()%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%20%0D%0A%20%20%20%20%7D%20%0D%0A%7D%20%0D%0Afunction%20fCkBrs()%20%0D%0A%7B%20%0D%0Aswitch%20(navigator.appName)%20%0D%0A%7B%20%0D%0Acase%20'Opera'%3A%20return%202%3B%20%0D%0Acase%20'Netscape'%3A%20return%203%3B%20%0D%0Adefault%3A%20return%201%3B%20%0D%0A%7D%20%0D%0A%7D%20%20%0D%0Afunction%20getOffsete%20(e%2Co)%20%7B%20%0D%0A%20%20%20%20var%20e%3De%7C%7Cwindow.event%3B%20%0D%0A%20%20%20%20var%20eSrc%3De.srcElement%7C%7Ce.target%3B%20%0D%0A%20%20%20%20if(eSrc!%3Do)%7BgetOffsete(e.offsetParent)%7D%20%0D%0A%7D%20%0D%0Avar%20DragZindexNumber%3D10%3B%20%0D%0Afunction%20Xdrag(obj%2Codrag)%7B%20%0D%0Avar%20ex%2Cxy%2Ctag%3D0%3B%20%0D%0Avar%20odrag%3Dodrag%3Fodrag%3Aobj%20%0D%0Aodrag.style.cursor%3D%22move%22%3B%20%0D%0Aif(tag%3D%3D0)%7B%20%0D%0Aodrag.onmousedown%3Dfunction(e)%20%0D%0A%20%20%20%20%7B%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20obj.style.zIndex%3DDragZindexNumber%2B%2B%3B%20%0D%0A%20%20%20%20%20%20%20%20Xtransp(obj%2C%22start%22)%20%0D%0A%20%20%20%20%20%20%20%20tag%3D1%3B%20%0D%0A%20%20%20%20%20%20%20%20var%20e%20%3D%20e%7C%7Cwindow.event%3B%20%0D%0A%20%20%20%20%20%20%20%20ex%3De.clientX-obj.offsetLeft%3B%20%0D%0A%20%20%20%20%20%20%20%20ey%3De.clientY-obj.offsetTop%3B%20%0D%0A%20%20%20%20%20%20%20%20var%20tempDiv%3DXCreateElement(%22div%22)%3B%20%0D%0A%20%20%20%20%20%20%20%20XSetCss(tempDiv%2C%7Bwidth%3Aobj.offsetWidth%2B%22px%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20height%3Aobj.offsetHeight%2B%22px%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20border%3A%221px%20dotted%20red%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20position%3A%22absolute%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20left%3Aobj.offsetLeft%2B%22px%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20top%3Aobj.offsetTop%2B%22px%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20zIndex%3A999%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%20%0D%0A%20%20%20%20%20%20%20%20this.ele%3DtempDiv%3B%20%0D%0A%20%20%20%20%20%20%20%20fDragStart(tempDiv)%3B%20%0D%0A%20%20%20%20%20%20%20%20document.body.onmousemove%3Dfunction(e)%7B%20%0D%0A%20%20%20%20%20%20%20%20if(tag%3D%3D1)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20e%3De%7C%7Cwindow.event%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(tempDiv%2C%7Bleft%3Ae.clientX-ex%2B%22px%22%2Ctop%3Ae.clientY-ey%2B%22px%22%7D)%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20else%7Bif(!tempDiv%3D%3Dnull)tempDiv.parentNode.removeChild(tempDiv)%7D%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20tempDiv.onmouseup%3Dfunction(e)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20var%20e%3De%7C%7Cwindow.event%3B%20%0D%0A%20%20%20%20%20%20%20%20fDragEnd(tempDiv)%3B%20%0D%0A%20%20%20%20%20%20%20%20obj.style.position%3D%22absolute%22%3B%20%0D%0A%20%20%20%20%20%20%20%20Xtransp(obj%2C%22end%22)%3B%20%0D%0A%20%20%20%20%20%20%20%20Xmove(obj%2CtempDiv.offsetLeft%2CtempDiv.offsetTop)%3B%20%0D%0A%20%20%20%20%20%20%20%20tempDiv.parentNode.removeChild(tempDiv)%3B%20%0D%0A%20%20%20%20%20%20%20%20tag%3D0%3B%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%7D%20%0D%0A%7D%20%0D%0A%7D%20%0D%0Afunction%20Xcover(color%2Cnum)%7B%2F*color%3A%E9%81%AE%E7%BD%A9%E7%9A%84%E8%83%8C%E6%99%AF%E8%89%B2%20eg%3A%20red%2F%23cbcbcb%2C%20num%3A1-100%E5%86%85%E7%9A%84%E6%95%B4%E6%95%B0*%2F%20%0D%0A%20%20%20%20var%20cDiv%3D%7B%7D%3B%20%0D%0A%20%20%20%20this.color%3Dcolor%3B%20%0D%0A%20%20%20%20this.num%3Dnum%3B%20%0D%0A%20%20%20%20this.start%3Dfunction()%7B%20%0D%0A%20%20%20%20%20%20%20%20cDiv%3DXCreateElement(%22div%22)%3B%20%0D%0A%20%20%20%20%20%20%20%20XSetCss(cDiv%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20position%3A%22absolute%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20top%3A%220px%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20left%3A%220px%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20zIndex%3A2%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20width%3A%220px%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20margin%3A%220px%20auto%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20background%3Athis.color%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20filter%3A%22Alpha(Opacity%3D%22%2Bthis.num%2B%22)%22%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20opacity%3Athis.num%2F100%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%20%0D%0A%20%20%20%20%20%20%20%20cDiv.innerText%3D%22%3Ch3%3E%E5%8F%8C%E5%87%BB%E5%85%B3%E9%97%AD%3C%2Fh3%3E%22%3B%20%0D%0A%20%20%20%20%20%20%20%20XslideDown(cDiv%2C%22width%22%2CgetCover().X-25%2C50)%3B%20%0D%0A%20%20%20%20%20%20%20%20XslideDown(cDiv%2C%22height%22%2CgetCover().H%2C30)%3B%20%0D%0A%20%20%20%20%20%20%20%20cDiv.ondblclick%3Dfunction()%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20cDiv.parentNode.removeChild(cDiv)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%7D%3B%20%0D%0A%20%20%20%20this.stop%3Dfunction()%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20cDiv.parentNode.removeChild(cDiv)%3B%20%0D%0A%20%20%20%20%7D%3B%20%0D%0A%7D%20%0D%0Afunction%20getCover()%7B%20%0D%0A%20%20%20%20var%20m%3D%7B%7D%20%0D%0A%20%20%20%20%20m.H%3Dscreen.availHeight%3Edocument.documentElement.scrollHeight%3Fscreen.availHeight%3Adocument.documentElement.scrollHeight%3B%20%0D%0A%20%20%20%20%20m.X%3Dscreen.availwidth%3Edocument.documentElement.scrollWidth%3Fscreen.availWidth%3Adocument.documentElement.scrollWidth%3B%20%0D%0A%20%20%20%20return%20m%3B%20%0D%0A%7D%20%0D%0A%3C%2Fscript%3E"> </head> <body> <div id="aa"></div> <div id="test"> <h1 id="dd">Just a Test</h1> <input type="button" id="test1" value="XslideUp-H" /> <input type="button" id="test2" value="XslideDown-H" /> <input type="button" id="test3" value="XslideUp-W" /> <input type="button" id="test4" value="XslideDown-W" /> <input type="button" id="test5" value="Xcover" /> <input type="button" id="test6" value="Xmove" /> <input type="button" id="test7" value="Xdrag" /> </div> <div id="odiv"> <h1 id="oTitle">什么时候能拖动我啊</h1> <ul> <li>Author:popper.w</li> <li>Email:popper11@126.com</li> <li>QQ:84101340</li> <li>webSite: [url]www.hongwei2008.cn[/url]</li> </ul> </div> <div id="ho"></div> </body> </html> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%20%0D%0A%24(%22test1%22).onclick%3Dfunction()%7B%20%0D%0AXslideUp(%24(%22odiv%22)%2C%22height%22%2C20%2C10)%3B%20%0D%0A%7D%20%0D%0A%24(%22test2%22).onclick%3Dfunction()%7B%20%0D%0AXslideDown(%24(%22odiv%22)%2C%22height%22%2C200%2C10)%3B%20%0D%0A%7D%20%0D%0A%24(%22test3%22).onclick%3Dfunction()%7B%20%0D%0AXslideUp(%24(%22odiv%22)%2C%22width%22%2C100%2C10)%3B%20%0D%0A%7D%20%0D%0A%24(%22test4%22).onclick%3Dfunction()%7B%20%0D%0AXslideDown(%24(%22odiv%22)%2C%22width%22%2C400%2C10)%3B%20%0D%0A%7D%20%0D%0Avar%20m%3Dnew%20Xcover(%22yellow%22%2C50)%3B%20%0D%0A%24(%22test5%22).onclick%3Dfunction()%7B%20%0D%0A%20%20%20%20%2F%2F%20%0D%0A%20%20%20%20%2F%2FXdrag(%24(%22test%22)%2C%24(%22dd%22))%3B%20%0D%0A%20%20%20%20m.start()%3B%20%0D%0A%20%20%20%20%2F%2F%20%0D%0A%7D%20%0D%0A%24(%22test6%22).onclick%3Dfunction()%7B%20%0D%0A%20%20%20%20Xmove(%24(%22ho%22)%2C50%2C100)%3B%20%0D%0A%7D%20%0D%0A%24(%22test7%22).onclick%3Dfunction()%7B%20%0D%0AXSetCss(%24(%22oTitle%22)%2C%7Bheight%3A%2230px%22%2ClineHeight%3A%2230px%22%2CtextIndent%3A%2220px%22%2CfontSize%3A%2212px%22%2Cbackground%3A%22%23cbcbcb%22%7D)%20%0D%0AXdrag(%24(%22ho%22))%20%0D%0AXdrag(%24(%22odiv%22)%2C%24(%22oTitle%22))%3B%20%0D%0A%7D%20%0D%0A%3C%2Fscript%3E">
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
2 层打开效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body{} #main{width:500px; margin:100px; height:500px;border:1px solid red} #test{border:1px solid red;display:none;width:10px;height:10px; background:yellow} </style> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%20%0D%0A%2F*%20%20%0D%0Apopper.w%20code%20%0D%0Aclass%3A%20XopenDiv%20%0D%0Aversion%3A%201.0%20%0D%0Adate%3A%202008-5-19%20%0D%0A*%2F%20%0D%0A%3C%2Fscript%3E"> <title>Code By popper.w</title> </head> <body> <input type="button" value="点击打开" id="bt" /> <input type="button" value="点击关闭" id="bt1" /> <div id="main"> <div id="test"></div> </div> </body> </html> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%20%0D%0Afunction%20%24%20(o)%20%7B%20%0D%0A%20%20%20%20%20%20return%20document.getElementById(o)%3B%20%0D%0A%7D%20%0D%0Afunction%20XslideDown(obj%2Ctype%2CmX%2Cnum)%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(!type)%7Breturn%3B%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20type1%3Dtype%3D%3D%22height%22%3F%22marginTop%22%3A%22marginLeft%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20type2%3Dtype%3D%3D%22height%22%3F%22top%22%3A%22left%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype1%2CXgetOffset(obj)%5Btype2%5D%2B%22px%22%5D)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CXgetOffset(obj)%5Btype%5D%2Bnum%2B%22px%22%5D)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(XgetOffset(obj)%5Btype%5D%3CmX)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20setTimeout(function()%7BXslideDown(obj%2Ctype%2CmX%2Cnum)%3B%7D%2C10)%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CmX%5D)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20catch(e)%7B%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0Afunction%20XslideUp(obj%2Ctype%2CmX%2Cnum)%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if(!type)%7Breturn%3B%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20type1%3Dtype%3D%3D%22height%22%3F%22marginTop%22%3A%22marginLeft%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20type2%3Dtype%3D%3D%22height%22%3F%22top%22%3A%22left%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype1%2CXgetOffset(obj)%5Btype2%5D%2B%22px%22%5D)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CXgetOffset(obj)%5Btype%5D-num%2B%22px%22%5D)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(XgetOffset(obj)%5Btype%5D%3EmX)%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20setTimeout(function()%7BXslideUp(obj%2Ctype%2CmX%2Cnum)%3B%7D%2C1)%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XSetCss(obj%2C%5Btype%2CmX%5D)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj.style.display%3D%22none%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20catch(e)%7B%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0Afunction%20XSetCss(obj%2CcssArgs)%7B%20%0D%0A%20%20%20%20%20%20%20%20if(arguments.length%3D%3D2)%20%0D%0A%20%20%20%20%20%20%20%20%7B%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20if(cssArgs.constructor%3D%3DObject)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20for(var%20o%20in%20cssArgs)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(obj.style%5Bo%5D!%3D%22undefiend%22)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj.style%5Bo%5D%3DcssArgs%5Bo%5D%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%20if(cssArgs.constructor%3D%3DArray%26%26cssArgs.length%3D%3D2)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj.style%5BcssArgs%5B0%5D%5D%3DcssArgs%5B1%5D%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20%20%20%7D%20%0D%0A%7D%20%0D%0Afunction%20XgetOffset%20(obj)%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20height%3Aobj.offsetHeight%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20width%3Aobj.offsetWidth%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20top%3AparseInt((obj.parentNode.offsetHeight-obj.offsetHeight)%2F2)%2C%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20left%3AparseInt((obj.parentNode.offsetWidth-obj.offsetWidth)%2F2)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%0D%0A%7D%20%0D%0Afunction%20XopenDiv(o)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20o.style.display%3D%22block%22%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XslideDown(o%2C%22width%22%2C400%2C10)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20XslideDown(o%2C%22height%22%2C400%2C10)%3B%20%0D%0A%7D%20%0D%0Afunction%20XcloseDiv(o)%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XslideUp(o%2C%22width%22%2C10%2C10)%3B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20XslideUp(o%2C%22height%22%2C10%2C10)%3B%20%0D%0A%7D%20%0D%0A%24(%22bt%22).onclick%3Dfunction()%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20XopenDiv(%24(%22test%22))%20%0D%0A%7D%20%0D%0A%24(%22bt1%22).onclick%3Dfunction()%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20XcloseDiv(%24(%22test%22))%20%0D%0A%7D%20%0D%0A%3C%2Fscript%3E">
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程