Jump to content

alensky

Newbie
  • Posts

    1
  • Joined

  • Last visited

Everything posted by alensky

  1. Пришлось несколько расширить код, добавить переменные и функции, но результат есть. <HTML> <HEAD> <TITLE>Drag'n'Drop</TITLE> <META http-equiv="Content-Type" content="text/html; charset=windows-1251"> <style type="text/css"> .maximage { padding: 0px; border: solid 1px black; float: none; position: absolute; top: 20%; left: 122px; width: 630; FILTER: alpha(Opacity=85); display: block; z-index: 100; font-size: 12px; } .titles { background: #999999; padding: 5px; margin: 0px; border: solid 1px black; float: none; position: relative; display: block; font-size: 16px; font-weight: bold; color: #000000; cursor: move; } .bodys { background: #FFF; padding: 5px; margin: 0px; border: solid 1px black; float: none; position: relative; color: #000000; display: block; font-size: 14px; } .closes { font-size: 14px; color: #020167; font-weight: normal; text-decoration: none; font-weight: bold; cursor: pointer; } </style> </HEAD> <SCRIPT language="JavaScript"> function getTopPos(inputObj) { var returnValue = inputObj.offsetTop; while((inputObj = inputObj.offsetParent) != null){ if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop; } return returnValue; } function getLeftPos(inputObj) { var returnValue = inputObj.offsetLeft; while((inputObj = inputObj.offsetParent) != null){ if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft; } return returnValue; } var DDob; var subX, subY; function MD(id){ DDob=document.getElementById(id); if(DDob.style.position!='absolute') DDob.style.position='absolute'; X=(typeof(id)=='object')? id.clientX : event.clientX; Y=(typeof(id)=='object')? id.clientY : event.clientY; subX = event.clientX+document.body.scrollLeft - getLeftPos(DDob); subY = event.clientY+document.body.scrollTop - getTopPos(DDob); } function MM(e){ var X,Y; if(DDob){ X=(typeof(e)=='object')? e.clientX : event.clientX; Y=(typeof(e)=='object')? e.clientY : event.clientY; DDob.style.left=event.clientX+document.body.scrollLeft - subX; DDob.style.top=event.clientY+document.body.scrollTop - subY; return false; } } function MU(){ if(DDob){ DDob=null; } } document.onmouseup=MU; document.onmousemove=MM; </SCRIPT> <BODY> <div id="infos" class="maximage"> <div id="infostitle" class="titles" onmousedown="MD('infos');">Окошко</div> <div id="infosbody" class="bodys"></div> <div id="closes" class="titles2" style="text-align: center" onclick="infos.style.display='none'" title="Нажмите, чтобы закрыть окошко" onclick="if(infos.style.display=='block')infos.style.display='none';else infos.style.display='block'" onmousemove="closes.style.textDecoration='underline'" onmouseout="closes.style.textDecoration='none'"><span class="closes">Закрыть окошко</span></div> </div> <DIV id="simple" style="cursor:move;" onmousedown="MD(this.id);"> Перетащи меня! </DIV> </BODY> </HTML>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy