Показать сообщение отдельно
  #3 (permalink)  
Старый 19.04.2013, 17:21
Аспирант
Отправить личное сообщение для alex2012 Посмотреть профиль Найти все сообщения от alex2012
 
Регистрация: 05.01.2012
Сообщений: 76

Работает
<!--<!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>Документ без названия</title>


</head>
<body>



 <img src='http://img15.kanobu.net/c/a5dac4b489ba89294da58d9988876d4d/220x313/games/42/120816e1b1474d8aad3ed0fa663c0e8f' style="position: absolute; left:0; top:1;  z-index:21; width:50px; "   id="img2"/>

 </body>
</html>


<script type="text/javascript" >
//elemX=0;// Глобальная координата x нажатия мыши относительно элемента
elemY=0;// Глобальная координата y нажатия мыши относительно элемента
drag=false;// Глобальная переменная, разрешающая или запрещающая перемещение элемента
function $$(id)
{
return document.getElementById(id);
}
$$('img2').onmousedown = function(e){

			   e = e || window.event;
			
			  elemY=e.clientY+document.body.scrollTop-parseInt($$('img2').style.top);
			 
			  drag=true;
                          }
$$('img2').ondragstart = function() {return false;}
document.onmouseup = function() {drag=false; document.getElementById("img2").style.cursor = 'default'; }
document.onmousemove = function(e) {
			e = e || window.event;
			
			ely=parseInt(e.clientY)-elemY;
			if(drag){
			document.getElementById("img2").style.cursor = 'move';//wait
		
			$$('img2').style.top=e.clientY+document.body.scrollTop-elemY;
		
			var photo_height = document.getElementById("img2"); 
            heightImg = photo_height.height;
			
			var Newtop = e.clientY+document.body.scrollTop-elemY;
			var Newheight = heightImg;
			var parentHeight = 300;
			deltaBottom = parentHeight - (Newtop + Newheight);
			}
			
	
			
			}
	</script>

Последний раз редактировалось alex2012, 19.04.2013 в 17:45.
Ответить с цитированием