Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> pozycja scroll w oknie
nospor
post
Post #1





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Mam sobie stronkę, zawiera dużo treści w body więc jest scroll na całym oknie. No i podczas scrollowania chce pobrać aktualną pozycję scrolla i mam problem bo nie jestem w stanie tego zrobić. O to kod:
Kod
    jQuery(window).scroll(function(){
        var b = document.body;
        console.log(b.scrollTop);
        console.log(b.scrollHeight);
        console.log(b.offsetHeight);
    
    });

Kombinowałem różnych wariacji i zawsze albo mam 0 albo maksymalną pozycję scrolla. Nigdy nie mam aktualnej...
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
sowiq
post
Post #2





Grupa: Zarejestrowani
Postów: 1 890
Pomógł: 339
Dołączył: 14.12.2006
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Kod
jQuery(window).scroll(function(){
        console.log($(this).scrollTop());
});
Go to the top of the page
+Quote Post
nospor
post
Post #3





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Super, wielkie dzięki (IMG:style_emoticons/default/smile.gif)

A jak pobrać maksymalną wartość scrolla? Bo tu w zależności od przeglądarki to mam problem
Go to the top of the page
+Quote Post
sowiq
post
Post #4





Grupa: Zarejestrowani
Postów: 1 890
Pomógł: 339
Dołączył: 14.12.2006
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Kod
$(document).height() - $(window).height()


(IMG:style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post
nospor
post
Post #5





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Haha, jesteś genialny (IMG:style_emoticons/default/biggrin.gif) Dzięki (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.09.2025 - 15:31