Показать сообщение отдельно
  #9 (permalink)  
Старый 18.06.2009, 14:23
Аспирант
Отправить личное сообщение для Logo Посмотреть профиль Найти все сообщения от Logo
 
Регистрация: 15.03.2008
Сообщений: 91

Фух, наконец то получилось. Сразу не заметил ваше сообщение. В общем получилось решить задачу, скрестив ваш метод и Riim. А слова prototype я все из своего скрипта повырезал.
Рабочий пример
<!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>
<style type="text/css">
#button, #button2 {background:#f00; color:#fff; font-weight:bold; padding:3px 5px; cursor:pointer; float:left; position:relative}
#button2 {background:#f80;}
</style>
<script type="text/javascript">
window.onload= function() {
	obj= new myclass(document.getElementById('button'))
	obj2= new myclass(document.getElementById('button2'))
}
function myclass(objref, message) {
	this.message=message
	this.obj=objref
	var self = this;
	
	this.changecontent = function () {
	    this.obj.innerHTML=this.obj.innerHTML+' :)'
		this.animate()	
	}
	this.animate = function() {		
		if(this.timer==0) {
			this.intervalref=setInterval(function() {self.animate()}, 5)
			this.timer= 30 / 3
		} else {
			this.offset+= 3;
			this.obj.style.top=this.offset+'px'		
			this.timer--
		}	
		if(this.timer==0) {
			clearInterval(this.intervalref)	
		}
	}
		
	this.offset=0
	this.timer = 0
	this.intervalref
    this.obj.onclick = function() {self.changecontent()}; 
}	
</script>
</head>
<body>
<div id="button">нажмии меня</div>
<div id="button2">нажмии меня 2</div>
</body>
</html>
Ответить с цитированием