Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Galeria js obsługa wstecz itd.
wlamywacz
post 20.06.2008, 16:58:20
Post #1





Grupa: Zarejestrowani
Postów: 535
Pomógł: 27
Dołączył: 3.05.2005

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


Jak w tytule. Myślę nad tym aby do zmiennej ostanie dawać nr. ostatniej fotki. I dodawać do adresu #nr_fotki jednak jak przechwycić to że user użył cofnij? Może jakieś przykłady ? Z góry dzięki za pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
slammer
post 23.06.2008, 01:29:32
Post #2





Grupa: Zarejestrowani
Postów: 187
Pomógł: 6
Dołączył: 31.08.2005
Skąd: Bielsko-Biała

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


Zainteresował mnie ten problem więc troszke poszperałem i znalazłem to:
  1. <script type='text/javascript'>
  2. function CheckForHash(){
  3. if(document.location.hash){
  4. var HashLocationName = document.location.hash;
  5. HashLocationName = HashLocationName.replace("#","");
  6. document.getElementById(HashLocationName).style.display='block';
  7. document.getElementById('Intructions').style.display='none';
  8. for(var a=0; a<5; a++){
  9. if(HashLocationName != ('Show' +(a+1))){
  10. document.getElementById('Show'+(a+1)).style.display='none';
  11. }
  12. }
  13. }else{
  14. document.getElementById('Intructions').style.display='block';
  15. for(var a=0; a<5; a++){
  16. document.getElementById('Show'+(a+1)).style.display='none';
  17. }
  18. }
  19. }
  20. function RenameAnchor(anchorid, anchorname){
  21. document.getElementById(anchorid).name = anchorname; //this renames the anchor
  22. }
  23. function RedirectLocation(anchorid, anchorname, HashName){
  24. RenameAnchor(anchorid, anchorname);
  25. document.location = HashName;
  26. }
  27. var HashCheckInterval = setInterval("CheckForHash()", 500);
  28. window.onload = CheckForHash;
  29. </script>
  30. </head>
  31. <a id='LocationAnchor' name=''></a>
  32. <div id='linkholder'>
  33. <a href='javascript:RedirectLocation("LocationAnchor", "Show1", "#Show1");'>Display Option 1</a><br />
  34. <a href='javascript:RedirectLocation("LocationAnchor", "Show2", "#Show2");'>Display Option 2</a><br />
  35. <a href='javascript:RedirectLocation("LocationAnchor", "Show3", "#Show3");'>Display Option 3</a><br />
  36. <a href='javascript:RedirectLocation("LocationAnchor", "Show4", "#Show4");'>Display Option 4</a><br />
  37. <a href='javascript:RedirectLocation("LocationAnchor", "Show5", "#Show5");'>Display Option 5</a>
  38. </div>
  39. <div id='Show1' style='display:none;'>
  40. 1st Option
  41. </div>
  42. <div id='Show2' style='display:none;'>
  43. 2nd Option
  44. </div>
  45. <div id='Show3' style='display:none;'>
  46. 3rd Option
  47. </div>
  48. <div id='Show4' style='display:none;'>
  49. 4th Option
  50. </div>
  51. <div id='Show5' style='display:none;'>
  52. 5th Option
  53. </div>
  54. <div id='Intructions' style='display:block;'>
  55. Click on the above links to see different values, then use the back button to see your browsing history.
  56. </div>
  57. </body>
  58. </html>
Go to the top of the page
+Quote Post
wlamywacz
post 28.06.2008, 09:08:30
Post #3





Grupa: Zarejestrowani
Postów: 535
Pomógł: 27
Dołączył: 3.05.2005

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


Znam to rozwiązanie jednak bardzo martwi mnie ten element:
  1. var HashCheckInterval = setInterval("CheckForHash()", 500);

Może to mulić przeglądarkę na słabszych komputerach ;/
Go to the top of the page
+Quote Post
misterdexter
post 1.07.2008, 11:21:55
Post #4





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 15.06.2005

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


Jeśli dwa razy na sekundę wykonuje się pętle, to może być problem. Odciążyć trochę przeglądarkę można po prostu sprawdzając czy zaszły zmiany, wtedy spokojnie można zwiększyć częstotliwość sprawdzania.

  1. <head>
  2. <script type='text/javascript'>
  3. var change='#'; // zmienna sprawdzajaca
  4.  
  5. function CheckForHash(){
  6. if(document.location.hash){
  7. var HashLocationName = document.location.hash;
  8.  
  9. if(HashLocationName == change) return; // jesli taka jest zakladka, nie sprawdzamy dalej
  10. change = HashLocationName; // jesli sprawdzamy, zapamietujemy
  11.  
  12. HashLocationName = HashLocationName.replace("#","");
  13. document.getElementById(HashLocationName).style.display='block';
  14. document.getElementById('Intructions').style.display='none';
  15. for(var a=0; a<5; a++){
  16. if(HashLocationName != ('Show' +(a+1))){
  17. document.getElementById('Show'+(a+1)).style.display='none';
  18. }
  19. }
  20. }else{
  21. if(change == '') return; // podobnie tutaj
  22. change = ''; // zapamietac tez trzeba
  23.  
  24. document.getElementById('Intructions').style.display='block';
  25. for(var a=0; a<5; a++){
  26. document.getElementById('Show'+(a+1)).style.display='none';
  27. }
  28. }
  29. }
  30. function RenameAnchor(anchorid, anchorname){
  31. document.getElementById(anchorid).name = anchorname; //this renames the anchor
  32. }
  33. function RedirectLocation(anchorid, anchorname, HashName){
  34. RenameAnchor(anchorid, anchorname);
  35. document.location = HashName;
  36. }
  37. var HashCheckInterval = setInterval("CheckForHash()", 100); // a sprawdzac mozna spokojnie czesciej
  38. window.onload = CheckForHash;
  39. </script>
  40. </head>
  41. <body>
  42. <a id='LocationAnchor' name=''></a>
  43. <div id='linkholder'>
  44. <a href='javascript:RedirectLocation("LocationAnchor", "Show1", "#Show1");'>Display Option 1</a><br />
  45. <a href='javascript:RedirectLocation("LocationAnchor", "Show2", "#Show2");'>Display Option 2</a><br />
  46. <a href='javascript:RedirectLocation("LocationAnchor", "Show3", "#Show3");'>Display Option 3</a><br />
  47. <a href='javascript:RedirectLocation("LocationAnchor", "Show4", "#Show4");'>Display Option 4</a><br />
  48. <a href='javascript:RedirectLocation("LocationAnchor", "Show5", "#Show5");'>Display Option 5</a>
  49. </div>
  50. <div id='Show1' style='display:none;'>
  51. 1st Option
  52. </div>
  53. <div id='Show2' style='display:none;'>
  54. 2nd Option
  55. </div>
  56. <div id='Show3' style='display:none;'>
  57. 3rd Option
  58. </div>
  59. <div id='Show4' style='display:none;'>
  60. 4th Option
  61. </div>
  62. <div id='Show5' style='display:none;'>
  63. 5th Option
  64. </div>
  65. <div id='Intructions' style='display:block;'>
  66. Click on the above links to see different values, then use the back button to see your browsing history.
  67. </div>
  68. </body>
  69. </html>
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: 24.07.2025 - 15:31