Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript] Scroll position
shpaque
post 2.08.2018, 08:59:49
Post #1





Grupa: Zarejestrowani
Postów: 651
Pomógł: 3
Dołączył: 31.01.2011
Skąd: Warszawa

Ostrzeżenie: (10%)
X----


Witam serdecznie,
mam pytanko gdzie i czego szukac, jesli chce wywolac funkcje w przypadku nie tyle pozycji scroll a zeby identyfikował # i wtedy.

np jesli index.php#oferta (to menu oferta jest pogrubione)
jesli index.php#kontakt (to menu kontakt pogrubione)
Go to the top of the page
+Quote Post
trueblue
post 2.08.2018, 09:07:26
Post #2





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

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


document.location.hash


--------------------
Go to the top of the page
+Quote Post
shpaque
post 2.08.2018, 09:08:17
Post #3





Grupa: Zarejestrowani
Postów: 651
Pomógł: 3
Dołączył: 31.01.2011
Skąd: Warszawa

Ostrzeżenie: (10%)
X----


ok tylko dopytam - na pewno document. a nie window.?
Go to the top of the page
+Quote Post
trueblue
post 2.08.2018, 09:11:59
Post #4





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

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


Może być window.location, czy chociażby location, jako globalny obiekt.


--------------------
Go to the top of the page
+Quote Post
shpaque
post 2.08.2018, 09:54:32
Post #5





Grupa: Zarejestrowani
Postów: 651
Pomógł: 3
Dołączył: 31.01.2011
Skąd: Warszawa

Ostrzeżenie: (10%)
X----


ok dziekuje bardzo

ok to może jeszcze pomęczę, co dalej - to nie dziala - nei wiem cyz ma byc document ready czy nie

  1. $('document').ready(function() {
  2. if (typeof document.location.hash != 'undefined' && document.location.hash == '#bloc-oferta') {
  3. $('.menulist').css('font-weight', 600);
  4. }
  5. });


tak wyglada menu

  1. <ul class="menu text-left pull-left">
  2. <div class="link">
  3. <li class="pasek pull-left">
  4. <a class="menulist a-first text-left pull-left" href="./index.php#bloc-oferta">OFERTA</a>
  5. </li>
  6. </div>
  7. <div class="link">
  8. <li class="pasek pull-left">
  9. <a class="menulist text-left pull-left" href="./index.php#bloc-projekty">PROJEKTY</a>
  10. </li>
  11. </div>
  12. <div class="link">
  13. <li class="pasek pull-left">
  14. <a class="menulist text-left pull-left" href="./index.php#bloc-kontakt">KONTAKT</a>
  15. </li>
  16. </div>
  17. <div class="link">
  18. <li class="pasek pull-left">
  19. <a class="menulist text-left pull-left" href="./index.php#bloc-blog">BLOG</a>
  20. </li>
  21. </div>
  22. </ul>
Go to the top of the page
+Quote Post
trueblue
post 2.08.2018, 10:05:33
Post #6





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

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


W rodzinie czcionki jest font o wadze 600?
Dlaczego zmieniasz styl dla wszystkich elementów?


--------------------
Go to the top of the page
+Quote Post
shpaque
post 2.08.2018, 11:19:38
Post #7





Grupa: Zarejestrowani
Postów: 651
Pomógł: 3
Dołączył: 31.01.2011
Skąd: Warszawa

Ostrzeżenie: (10%)
X----


faktycznie jest 700 - a robie dla wszystkich bo zostawilem to pytanie dalej moge zrobic kazdemu id, ale chcialbym wiedziec jak rozpoznac po wartosci a

zrobilem jsfiddle tutaj:

https://jsfiddle.net/Lp2678d9/23/

juz znalazlem dlaczego to nei dziala.

pomimo, ze a href kieruje do index.php#costam, a nie samo #costam, skrypt wymaga przeladowania strony, dopiero jak ja odswieze z hasztagiem, skrypt dziala- jak tro rozwiazac?
Go to the top of the page
+Quote Post
trueblue
post 2.08.2018, 12:28:53
Post #8





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

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


https://developer.mozilla.org/en-US/docs/We...rs/onhashchange


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 23.04.2024 - 13:56