Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   не срабатывает event.returnValue (https://javascript.ru/forum/events/56819-ne-srabatyvaet-event-returnvalue.html)

sash003 06.07.2015 19:00

рони, чудасия какая-то, открываю ваш пример в ie, всё работает, открываю свой файлик - нет :( изза доктайпа html5 чтоли?

рони 06.07.2015 19:35

Цитата:

Сообщение от sash003
доктайпа html5 чтоли?

да
если нужно без DOCTYPE
тогда без document.querySelector
var input = document.getElementsByTagName("input")[0] ;

или document.getElementById

sash003 06.07.2015 22:30

рони, благодарю!
Я наверно вам уже надоел, но гляньте ещё, пожалуйста, делаю мини джейквери для народа, не хочет работать slideUp
function _init_(el){
       this.s = document.querySelectorAll(el);
   }
   
 // главная и самая сложная функшн
 function _A_(el){
     return new _init_(el)      
 }

_init_.prototype.css = function(obj){
    if(typeof obj === 'object'){
     for (var e = 0; e < this.s.length; e++){
         for (i in obj){
         this.s[e].style[i] = obj[i];   
     }   
     }
     return this;
    }
    else {
        if(obj === 'width') return this.s[0].offsetWidth;
        if(obj === 'height') return this.s[0].offsetHeight
        else return this.s[0].style[obj] || getComputedStyle(this.s[0])[obj];
    }    
} 

_init_.prototype.attr = function(){
    
}

_init_.prototype.slideUp = function (duration){
   
   this.css({'overflow' : 'hidden'});
   var height = parseInt(this.css('height'));
   for(var  i = 1; i <= height ; i++){      
       (function(i){
          setTimeout(function(){
                    this.css({'height' : (height-i)+'px'});  // this.css is not a function. хотя overflow устанавливает перед этим 
          }, i*duration/height);   
       })(i); 
    } 
    return this;
}

рони 06.07.2015 23:19

sash003,
таймер ничего не знает про твой this -- сохрани
31 var self = this;
37 self.css

sash003 06.07.2015 23:38

Не работает, консоль молчит как подкупленная :) Да что за напасть такая, что не копни, кругом засада :(

рони 06.07.2015 23:48

sash003,
делайте макет

рони 06.07.2015 23:55

sash003,
:-?
<!DOCTYPE HTML>



<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
   <style type="text/css">
   p{
     height: 200px;
     background-color: #0000CC;
   }

   </style>
</head>

<body>

<p></p>
<script>
function _init_(el){
       this.s = document.querySelectorAll(el);
   }

 // главная и самая сложная функшн
 function _A_(el){
     return new _init_(el)
 }

_init_.prototype.css = function(obj){
    if(typeof obj === 'object'){
     for (var e = 0; e < this.s.length; e++){
         for (i in obj){
         this.s[e].style[i] = obj[i];
     }
     }
     return this;
    }
    else {
        if(obj === 'width') return this.s[0].offsetWidth;
        if(obj === 'height') return this.s[0].offsetHeight
        else return this.s[0].style[obj] || getComputedStyle(this.s[0])[obj];
    }
}

_init_.prototype.attr = function(){

}

_init_.prototype.slideUp = function (duration){
   var self = this;
   this.css({'overflow' : 'hidden'});
   var height = parseInt(this.css('height'));
   for(var  i = 1; i <= height ; i++){
       (function(i){
          setTimeout(function(){
                    self.css({'height' : (height-i)+'px'});  // this.css is not a function. хотя overflow устанавливает перед этим
          }, i*duration/height);
       })(i);
    }
    return this;
}

var x = _A_("p");
x.slideUp(3000)
</script>
</body>

</html>

sash003 07.07.2015 01:44

БЛАГОДАРЮ, ДРУЖИЩЕ!
Я как всегда не туда смотрел :) ТОЛЬКО для блочных элементов работает, а я пытался ссылку скрыть. Даже для инлайн блок не работает

kostyanet 07.07.2015 05:18

Тему не читал, ибо ишаку бортовой номер 8 давно уже показывают сервер нот фаунд.


Часовой пояс GMT +3, время: 10:26.