Показать сообщение отдельно
  #4 (permalink)  
Старый 15.01.2012, 19:55
Особый гость
Посмотреть профиль Найти все сообщения от monolithed
 
Регистрация: 02.04.2010
Сообщений: 4,260

<img src="http://javascript.ru/forum/images/ca_serenity/misc/logo.gif" id="id" alt="" />

<script type="text/javascript">
!function(id, x, y, drag) {
	var scroll = {
		left: function(event) {
			return event.clientX + document.body.scrollLeft;
		},
		top: function(event) {
			return event.clientY + document.body.scrollTop;
		}
	};

	id.style.cssText = "cursor: move; position: absolute; left: 0px; top: 0px";

	id.onmousedown = function(event){
		event = event || window.event;
		x = scroll.left(event) - parseInt(id.style.left);
		y = scroll.top(event) - parseInt(id.style.top);
		drag = 1;
	};

	document.onmouseup = function() {
		drag = 0;
	};

	document.onmousemove = function(event) {
		event = event || window.event;
		if(drag) {
			id.style.left = scroll.left(event) - x;
			id.style.top = scroll.top(event) - y;
		}
	};
}(document.getElementById('id'), 0, 0, 0);
</script>
Ответить с цитированием